diff --git a/src/main/java/de/hysky/skyblocker/skyblock/WardrobeKeybinds.java b/src/main/java/de/hysky/skyblocker/skyblock/WardrobeKeybinds.java index 795acf1ce1..3aa5ffc7e2 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/WardrobeKeybinds.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/WardrobeKeybinds.java @@ -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; @@ -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\\)"); @@ -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 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; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/SlotTextManager.java b/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/SlotTextManager.java index fcfb4611a4..da1dc6fe62 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/SlotTextManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/SlotTextManager.java @@ -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.*; @@ -49,7 +50,8 @@ public class SlotTextManager { new StatsTuningAdder(), ChocolateFactorySolver.INSTANCE, new EvolvingItemAdder(), - new NewYearCakeAdder() + new NewYearCakeAdder(), + WardrobeKeybinds.INSTANCE }; private static final ArrayList currentScreenAdders = new ArrayList<>(); private static final KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.skyblocker.slottext", GLFW.GLFW_KEY_LEFT_ALT, "key.categories.skyblocker"));