From 411c196e55db4ef90c48bfd3355ec508884582e0 Mon Sep 17 00:00:00 2001 From: vicisacat Date: Sun, 17 Mar 2024 13:15:28 +0100 Subject: yeet the string and rename stuff --- .../mixin/HandledScreenProviderMixin.java | 8 +-- .../item/SkyblockCraftingTableHandler.java | 68 ---------------------- .../skyblock/item/SkyblockCraftingTableScreen.java | 19 ++---- .../item/SkyblockCraftingTableScreenHandler.java | 68 ++++++++++++++++++++++ 4 files changed, 77 insertions(+), 86 deletions(-) delete mode 100644 src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableHandler.java create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableScreenHandler.java diff --git a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java index 35618798..08a9ee6f 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java @@ -3,7 +3,7 @@ package de.hysky.skyblocker.mixin; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen; -import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableHandler; +import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableScreenHandler; import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableScreen; import de.hysky.skyblocker.utils.Utils; import net.minecraft.client.MinecraftClient; @@ -46,9 +46,9 @@ public interface HandledScreenProviderMixin { ci.cancel(); } else if (Utils.isOnSkyblock() && screenHandler instanceof GenericContainerScreenHandler containerScreenHandler && name.getString().toLowerCase().contains("craft item")) { - SkyblockCraftingTableHandler skyblockCraftingTableHandler = new SkyblockCraftingTableHandler(containerScreenHandler, player.getInventory()); - client.player.currentScreenHandler = skyblockCraftingTableHandler; - client.setScreen(new SkyblockCraftingTableScreen(skyblockCraftingTableHandler, player.getInventory(), Text.literal("Craft Item"))); + SkyblockCraftingTableScreenHandler skyblockCraftingTableScreenHandler = new SkyblockCraftingTableScreenHandler(containerScreenHandler, player.getInventory()); + client.player.currentScreenHandler = skyblockCraftingTableScreenHandler; + client.setScreen(new SkyblockCraftingTableScreen(skyblockCraftingTableScreenHandler, player.getInventory(), Text.literal("Craft Item"))); ci.cancel(); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableHandler.java b/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableHandler.java deleted file mode 100644 index 0c2fb224..00000000 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -package de.hysky.skyblocker.skyblock.item; - -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.Inventory; -import net.minecraft.screen.GenericContainerScreenHandler; -import net.minecraft.screen.ScreenHandlerType; -import net.minecraft.screen.slot.Slot; - -import java.util.Arrays; - -public class SkyblockCraftingTableHandler extends GenericContainerScreenHandler { - - private static final int[] normalSlots = new int[]{ - 10, 11, 12, 16, - 19, 20, 21, 23, 25, - 28, 29, 30, 34 - }; - public SkyblockCraftingTableHandler(ScreenHandlerType type, int syncId, PlayerInventory playerInventory, Inventory inventory, int rows) { - super(type, syncId, playerInventory, inventory, rows); - for (int i = 0; i < rows*9; i++) { - Slot originalSlot = slots.get(i); - if (Arrays.binarySearch(normalSlots, i) >= 0) { - int[] coords = getCoords(i); - Slot slot = new Slot(originalSlot.inventory, originalSlot.getIndex(), coords[0], coords[1]); - slot.id = i; - slots.set(i, slot); - } else { - DisabledSlot slot = new DisabledSlot(originalSlot.inventory, originalSlot.getIndex(), originalSlot.x, originalSlot.y); - slot.id = i; - slots.set(i, slot); - } - } - int yOffset = (rows - 4) * 18 + 19; - for (int i = rows*9; i < slots.size(); i++) { - Slot originalSlot = slots.get(i); - Slot slot = new Slot(originalSlot.inventory, originalSlot.getIndex(), originalSlot.x, originalSlot.y - yOffset); - slot.id = i; - slots.set(i, slot); - } - } - - public SkyblockCraftingTableHandler(GenericContainerScreenHandler handler, PlayerInventory playerInventory) { - this(handler.getType(), handler.syncId, playerInventory, handler.getInventory(), handler.getRows()); - } - - private int[] getCoords(int slot) { - if (slot == 23) return new int[]{124, 35}; - if (slot == 16 || slot == 25 || slot == 34) { - int y = (slot/9 - 1) * 18 + 8; - return new int[]{174, y}; - } - int gridX = slot%9 - 1; - int gridY = slot/9 - 1; - return new int[]{30 + gridX*18, 17+gridY*18}; - } - - public static class DisabledSlot extends Slot { - - public DisabledSlot(Inventory inventory, int index, int x, int y) { - super(inventory, index, x, y); - } - - @Override - public boolean isEnabled() { - return false; - } - } -} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableScreen.java index 2dbf1868..13c04e8b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableScreen.java @@ -8,7 +8,6 @@ import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.TexturedButtonWidget; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.SimpleInventory; @@ -24,9 +23,8 @@ import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.math.RotationAxis; -public class SkyblockCraftingTableScreen extends HandledScreen { +public class SkyblockCraftingTableScreen extends HandledScreen { private static final Identifier TEXTURE = new Identifier("textures/gui/container/crafting_table.png"); protected static final ButtonTextures MORE_CRAFTS_TEXTURES = new ButtonTextures( new Identifier(SkyblockerMod.NAMESPACE, "quick_craft/more_button"), @@ -38,7 +36,7 @@ public class SkyblockCraftingTableScreen extends HandledScreen { this.recipeBook.toggleOpen(); @@ -88,13 +86,6 @@ public class SkyblockCraftingTableScreen extends HandledScreen { + static class DummyRecipeScreenHandler extends AbstractRecipeScreenHandler { - public Dummy() { + public DummyRecipeScreenHandler() { super(ScreenHandlerType.GENERIC_9X6, -69); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableScreenHandler.java b/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableScreenHandler.java new file mode 100644 index 00000000..1d66c661 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockCraftingTableScreenHandler.java @@ -0,0 +1,68 @@ +package de.hysky.skyblocker.skyblock.item; + +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.Inventory; +import net.minecraft.screen.GenericContainerScreenHandler; +import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.screen.slot.Slot; + +import java.util.Arrays; + +public class SkyblockCraftingTableScreenHandler extends GenericContainerScreenHandler { + + private static final int[] normalSlots = new int[]{ + 10, 11, 12, 16, + 19, 20, 21, 23, 25, + 28, 29, 30, 34 + }; + public SkyblockCraftingTableScreenHandler(ScreenHandlerType type, int syncId, PlayerInventory playerInventory, Inventory inventory, int rows) { + super(type, syncId, playerInventory, inventory, rows); + for (int i = 0; i < rows*9; i++) { + Slot originalSlot = slots.get(i); + if (Arrays.binarySearch(normalSlots, i) >= 0) { + int[] coords = getCoords(i); + Slot slot = new Slot(originalSlot.inventory, originalSlot.getIndex(), coords[0], coords[1]); + slot.id = i; + slots.set(i, slot); + } else { + DisabledSlot slot = new DisabledSlot(originalSlot.inventory, originalSlot.getIndex(), originalSlot.x, originalSlot.y); + slot.id = i; + slots.set(i, slot); + } + } + int yOffset = (rows - 4) * 18 + 19; + for (int i = rows*9; i < slots.size(); i++) { + Slot originalSlot = slots.get(i); + Slot slot = new Slot(originalSlot.inventory, originalSlot.getIndex(), originalSlot.x, originalSlot.y - yOffset); + slot.id = i; + slots.set(i, slot); + } + } + + public SkyblockCraftingTableScreenHandler(GenericContainerScreenHandler handler, PlayerInventory playerInventory) { + this(handler.getType(), handler.syncId, playerInventory, handler.getInventory(), handler.getRows()); + } + + private int[] getCoords(int slot) { + if (slot == 23) return new int[]{124, 35}; + if (slot == 16 || slot == 25 || slot == 34) { + int y = (slot/9 - 1) * 18 + 8; + return new int[]{174, y}; + } + int gridX = slot%9 - 1; + int gridY = slot/9 - 1; + return new int[]{30 + gridX*18, 17+gridY*18}; + } + + public static class DisabledSlot extends Slot { + + public DisabledSlot(Inventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } + + @Override + public boolean isEnabled() { + return false; + } + } +} -- cgit