From 28c34fe4b127958b1b70ce4224c284ff66f61204 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Thu, 9 Jan 2025 06:27:24 +0100 Subject: [PATCH] add compat for CraftingTweaks --- dependencies.gradle | 6 ++-- .../ezstorage/gui/GuiCraftingCore.java | 7 +++++ .../ezstorage/gui/GuiStorageCore.java | 6 ++++ .../integration/IntegrationUtils.java | 25 ++++++++++++++++ .../ezstorage/integration/ModIds.java | 1 + .../craftingtweaks/CraftingTweaksUtils.java | 29 +++++++++++++++++++ .../zerofall/ezstorage/proxy/ClientProxy.java | 8 ++--- .../zerofall/ezstorage/proxy/CommonProxy.java | 2 ++ 8 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/zerofall/ezstorage/integration/craftingtweaks/CraftingTweaksUtils.java diff --git a/dependencies.gradle b/dependencies.gradle index d57b5b3..eae9f95 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -35,7 +35,9 @@ */ dependencies { implementation("com.github.GTNewHorizons:NotEnoughItems:2.7.13-GTNH:dev") + runtimeOnly('com.github.GTNewHorizons:waila:1.8.2:dev') {transitive = false} + api("com.github.GTNewHorizons:GTNHLib:0.6.0:dev") { transitive = false } + devOnlyNonPublishable("com.github.GTNewHorizons:Jabba:1.5.1:dev") { transitive = false } implementation(rfg.deobf("curse.maven:et-futurum-requiem-441392:5873837")) { transitive = false } - api("com.github.GTNewHorizons:GTNHLib:0.6.0:dev") - devOnlyNonPublishable("com.github.GTNewHorizons:Jabba:1.5.1:dev") + implementation(rfg.deobf("curse.maven:crafting-tweaks-233071:2457094")) { transitive = false } } diff --git a/src/main/java/com/zerofall/ezstorage/gui/GuiCraftingCore.java b/src/main/java/com/zerofall/ezstorage/gui/GuiCraftingCore.java index c776c9f..e519a19 100644 --- a/src/main/java/com/zerofall/ezstorage/gui/GuiCraftingCore.java +++ b/src/main/java/com/zerofall/ezstorage/gui/GuiCraftingCore.java @@ -6,6 +6,7 @@ import com.zerofall.ezstorage.Reference; import com.zerofall.ezstorage.container.ContainerStorageCoreCrafting; +import com.zerofall.ezstorage.integration.IntegrationUtils; public class GuiCraftingCore extends GuiStorageCore { @@ -15,6 +16,12 @@ public GuiCraftingCore(EntityPlayer player, World world, int x, int y, int z) { this.ySize = 256; } + @Override + public void initGui() { + super.initGui(); + IntegrationUtils.applyCraftingTweaks(this, extraButtons, inventorySlots.inventorySlots.size() - 9); + } + @Override public int rowsVisible() { return 5; diff --git a/src/main/java/com/zerofall/ezstorage/gui/GuiStorageCore.java b/src/main/java/com/zerofall/ezstorage/gui/GuiStorageCore.java index b6c82c7..dafaeb8 100644 --- a/src/main/java/com/zerofall/ezstorage/gui/GuiStorageCore.java +++ b/src/main/java/com/zerofall/ezstorage/gui/GuiStorageCore.java @@ -6,6 +6,7 @@ import java.util.List; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.inventory.GuiContainer; @@ -44,6 +45,7 @@ public class GuiStorageCore extends GuiContainer { private GuiTextField searchField; private List filteredList; private ItemStack mouseOverItem; + protected List extraButtons; @Override public void initGui() { @@ -61,6 +63,7 @@ public void initGui() { this.searchField.setFocused(true); this.searchField.setText(""); filteredList = new ArrayList(this.tileEntity.inventory.inventory); + extraButtons = new ArrayList(); } public GuiStorageCore(EntityPlayer player, World world, int x, int y, int z) { @@ -84,6 +87,9 @@ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, i this.mc.renderEngine.bindTexture(searchBar); drawTexturedModalRect(this.guiLeft + 8, this.guiTop + 4, 80, 4, 90, 12); this.searchField.drawTextBox(); + for (GuiButton button : extraButtons) { + button.drawButton(mc, mouseX, mouseY); + } } @Override diff --git a/src/main/java/com/zerofall/ezstorage/integration/IntegrationUtils.java b/src/main/java/com/zerofall/ezstorage/integration/IntegrationUtils.java index dd9c627..083181e 100644 --- a/src/main/java/com/zerofall/ezstorage/integration/IntegrationUtils.java +++ b/src/main/java/com/zerofall/ezstorage/integration/IntegrationUtils.java @@ -1,15 +1,40 @@ package com.zerofall.ezstorage.integration; +import java.util.List; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; +import com.zerofall.ezstorage.gui.GuiStorageCore; +import com.zerofall.ezstorage.integration.craftingtweaks.CraftingTweaksUtils; import com.zerofall.ezstorage.integration.etfuturum.EtFuturumUtils; +import com.zerofall.ezstorage.nei.NeiHandler; public class IntegrationUtils { + public static void init() { + if (ModIds.CRAFTINGTWEAKS.isLoaded()) { + CraftingTweaksUtils.init(); + } + } + + public static void initClient() { + if (ModIds.NEI.isLoaded()) { + NeiHandler.init(); + } + } + public static boolean isSpectatorMode(EntityPlayer player) { if (ModIds.ETFUTURUM.isLoaded()) { return EtFuturumUtils.isSpectatorMode(player); } return false; } + + public static void applyCraftingTweaks(GuiScreen gui, List buttons, int startIndex) { + if (ModIds.CRAFTINGTWEAKS.isLoaded() && gui instanceof GuiStorageCore guiStorageCore) { + CraftingTweaksUtils.initGui(guiStorageCore, buttons, startIndex); + } + } } diff --git a/src/main/java/com/zerofall/ezstorage/integration/ModIds.java b/src/main/java/com/zerofall/ezstorage/integration/ModIds.java index 51bd74b..12aef83 100644 --- a/src/main/java/com/zerofall/ezstorage/integration/ModIds.java +++ b/src/main/java/com/zerofall/ezstorage/integration/ModIds.java @@ -4,6 +4,7 @@ public enum ModIds { + CRAFTINGTWEAKS("craftingtweaks"), NEI("NotEnoughItems"), ETFUTURUM("etfuturum"); diff --git a/src/main/java/com/zerofall/ezstorage/integration/craftingtweaks/CraftingTweaksUtils.java b/src/main/java/com/zerofall/ezstorage/integration/craftingtweaks/CraftingTweaksUtils.java new file mode 100644 index 0000000..aedbe84 --- /dev/null +++ b/src/main/java/com/zerofall/ezstorage/integration/craftingtweaks/CraftingTweaksUtils.java @@ -0,0 +1,29 @@ +package com.zerofall.ezstorage.integration.craftingtweaks; + +import java.util.List; + +import net.blay09.mods.craftingtweaks.SimpleTweakProviderImpl; +import net.blay09.mods.craftingtweaks.api.CraftingTweaksAPI; +import net.blay09.mods.craftingtweaks.api.SimpleTweakProvider; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.util.EnumFacing; + +import com.zerofall.ezstorage.Reference; +import com.zerofall.ezstorage.container.ContainerStorageCore; +import com.zerofall.ezstorage.gui.GuiStorageCore; + +public class CraftingTweaksUtils { + + private static SimpleTweakProvider providerStorageCore; + + public static void init() { + providerStorageCore = new SimpleTweakProviderImpl(Reference.MOD_ID); + CraftingTweaksAPI.registerProvider(ContainerStorageCore.class, providerStorageCore); + } + + public static void initGui(GuiStorageCore gui, List buttons, int startIndex) { + providerStorageCore.setGrid(startIndex, 9); + providerStorageCore.setAlignToGrid(EnumFacing.WEST); + providerStorageCore.initGui(gui, buttons); + } +} diff --git a/src/main/java/com/zerofall/ezstorage/proxy/ClientProxy.java b/src/main/java/com/zerofall/ezstorage/proxy/ClientProxy.java index 4755963..eaa7103 100644 --- a/src/main/java/com/zerofall/ezstorage/proxy/ClientProxy.java +++ b/src/main/java/com/zerofall/ezstorage/proxy/ClientProxy.java @@ -1,8 +1,7 @@ package com.zerofall.ezstorage.proxy; import com.zerofall.ezstorage.EZStorage; -import com.zerofall.ezstorage.integration.ModIds; -import com.zerofall.ezstorage.nei.NeiHandler; +import com.zerofall.ezstorage.integration.IntegrationUtils; import cpw.mods.fml.common.event.FMLInitializationEvent; @@ -11,9 +10,6 @@ public class ClientProxy extends CommonProxy { @Override public void init(EZStorage instance, FMLInitializationEvent event) { super.init(instance, event); - - if (ModIds.NEI.isLoaded()) { - NeiHandler.init(); - } + IntegrationUtils.initClient(); } } diff --git a/src/main/java/com/zerofall/ezstorage/proxy/CommonProxy.java b/src/main/java/com/zerofall/ezstorage/proxy/CommonProxy.java index 98fb3e6..dc68677 100644 --- a/src/main/java/com/zerofall/ezstorage/proxy/CommonProxy.java +++ b/src/main/java/com/zerofall/ezstorage/proxy/CommonProxy.java @@ -9,6 +9,7 @@ import com.zerofall.ezstorage.events.XEventHandler; import com.zerofall.ezstorage.gui.GuiHandler; import com.zerofall.ezstorage.init.EZBlocks; +import com.zerofall.ezstorage.integration.IntegrationUtils; import com.zerofall.ezstorage.network.MyMessage; import com.zerofall.ezstorage.network.PacketHandler; import com.zerofall.ezstorage.network.RecipeMessage; @@ -36,5 +37,6 @@ public void preInit(EZStorage instance, FMLPreInitializationEvent event) { public void init(EZStorage instance, FMLInitializationEvent event) { EZBlocks.registerRecipes(); + IntegrationUtils.init(); } }