Skip to content

Commit

Permalink
Add wardrobe slot text
Browse files Browse the repository at this point in the history
  • Loading branch information
Emirlol committed Oct 21, 2024
1 parent 9b0f502 commit 82f1056
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
22 changes: 17 additions & 5 deletions src/main/java/de/hysky/skyblocker/skyblock/WardrobeKeybinds.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import de.hysky.skyblocker.annotations.Init;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.container.RegexContainerMatcher;
import de.hysky.skyblocker.skyblock.item.slottext.SimpleSlotTextAdder;
import de.hysky.skyblocker.skyblock.item.slottext.SlotText;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.client.screen.v1.ScreenKeyboardEvents;
import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents;
Expand All @@ -11,14 +12,18 @@
import net.minecraft.client.option.KeyBinding;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.text.Text;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;

import java.util.List;
import java.util.function.Predicate;

@SuppressWarnings("unused")
public class WardrobeKeybinds extends RegexContainerMatcher {
private static final WardrobeKeybinds INSTANCE = new WardrobeKeybinds();
public class WardrobeKeybinds extends SimpleSlotTextAdder {
public static final WardrobeKeybinds INSTANCE = new WardrobeKeybinds();

public WardrobeKeybinds() {
super("Wardrobe \\([12]/2\\)");
Expand Down Expand Up @@ -51,13 +56,20 @@ private static boolean allowInput(MinecraftClient client, HandledScreen<?> handl
i += 9 * 4;
ItemStack itemStack = handledScreen.getScreenHandler().getSlot(i).getStack();
// Check if the item in the slot is a swap/unequip item before going further.
// This prevents usage when the inventory hasn't loaded fully or when the slot pressed is locked (which would be meaningless to click)
// This prevents usage when the inventory hasn't loaded fully or when the slot pressed is locked or when the slot has no armor (which would be meaningless to click)
if (!itemStack.isOf(Items.PINK_DYE) && !itemStack.isOf(Items.LIME_DYE)) return true;
assert client.interactionManager != null;
client.interactionManager.clickSlot(handledScreen.getScreenHandler().syncId, i, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.PICKUP, client.player);
return false;
}

@Override
public @NotNull List<SlotText> getText(@Nullable Slot slot, @NotNull ItemStack stack, int slotId) {
if (!stack.isOf(Items.PINK_DYE) && !stack.isOf(Items.LIME_DYE)) return List.of();
if (!(slotId >= 36 && slotId <= 44)) return List.of();
return SlotText.bottomLeftList(Text.literal(String.valueOf(slotId - 35)).withColor(0x74c7ec));
}

@Override
public boolean isEnabled() {
return SkyblockerConfigManager.get().helpers.enableWardrobeHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.hysky.skyblocker.annotations.Init;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.WardrobeKeybinds;
import de.hysky.skyblocker.skyblock.bazaar.BazaarHelper;
import de.hysky.skyblocker.skyblock.chocolatefactory.ChocolateFactorySolver;
import de.hysky.skyblocker.skyblock.item.slottext.adders.*;
Expand Down Expand Up @@ -49,7 +50,8 @@ public class SlotTextManager {
new StatsTuningAdder(),
ChocolateFactorySolver.INSTANCE,
new EvolvingItemAdder(),
new NewYearCakeAdder()
new NewYearCakeAdder(),
WardrobeKeybinds.INSTANCE
};
private static final ArrayList<SlotTextAdder> currentScreenAdders = new ArrayList<>();
private static final KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.skyblocker.slottext", GLFW.GLFW_KEY_LEFT_ALT, "key.categories.skyblocker"));
Expand Down

0 comments on commit 82f1056

Please sign in to comment.