Skip to content

Commit

Permalink
add compat for CraftingTweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Pilzinsel64 committed Jan 9, 2025
1 parent bbd6a62 commit 28c34fe
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 8 deletions.
6 changes: 4 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
7 changes: 7 additions & 0 deletions src/main/java/com/zerofall/ezstorage/gui/GuiCraftingCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/zerofall/ezstorage/gui/GuiStorageCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,6 +45,7 @@ public class GuiStorageCore extends GuiContainer {
private GuiTextField searchField;
private List<ItemGroup> filteredList;
private ItemStack mouseOverItem;
protected List<GuiButton> extraButtons;

@Override
public void initGui() {
Expand All @@ -61,6 +63,7 @@ public void initGui() {
this.searchField.setFocused(true);
this.searchField.setText("");
filteredList = new ArrayList<ItemGroup>(this.tileEntity.inventory.inventory);
extraButtons = new ArrayList<GuiButton>();
}

public GuiStorageCore(EntityPlayer player, World world, int x, int y, int z) {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<GuiButton> buttons, int startIndex) {
if (ModIds.CRAFTINGTWEAKS.isLoaded() && gui instanceof GuiStorageCore guiStorageCore) {
CraftingTweaksUtils.initGui(guiStorageCore, buttons, startIndex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public enum ModIds {

CRAFTINGTWEAKS("craftingtweaks"),
NEI("NotEnoughItems"),
ETFUTURUM("etfuturum");

Expand Down
Original file line number Diff line number Diff line change
@@ -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<GuiButton> buttons, int startIndex) {
providerStorageCore.setGrid(startIndex, 9);
providerStorageCore.setAlignToGrid(EnumFacing.WEST);
providerStorageCore.initGui(gui, buttons);
}
}
8 changes: 2 additions & 6 deletions src/main/java/com/zerofall/ezstorage/proxy/ClientProxy.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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();
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/zerofall/ezstorage/proxy/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -36,5 +37,6 @@ public void preInit(EZStorage instance, FMLPreInitializationEvent event) {

public void init(EZStorage instance, FMLInitializationEvent event) {
EZBlocks.registerRecipes();
IntegrationUtils.init();
}
}

0 comments on commit 28c34fe

Please sign in to comment.