diff --git a/gradle.properties b/gradle.properties index 37870b4..ff3f27e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.daemon=false mc_version=1.7.10 nei_version=2.1.6-GTNH ae2_version=rv3-beta-52-GTNH -mod_version=1.2.8 +mod_version=1.2.9 forge_version=10.13.4.1614 mod_group=com.github.vfyjxf.neenergistics mod_id=neenergistics diff --git a/src/main/java/com/github/vfyjxf/nee/NotEnoughEnergistics.java b/src/main/java/com/github/vfyjxf/nee/NotEnoughEnergistics.java index f7ad40e..e0f6a4d 100644 --- a/src/main/java/com/github/vfyjxf/nee/NotEnoughEnergistics.java +++ b/src/main/java/com/github/vfyjxf/nee/NotEnoughEnergistics.java @@ -1,7 +1,9 @@ package com.github.vfyjxf.nee; import appeng.client.gui.implementations.GuiPatternTerm; +import appeng.client.gui.implementations.GuiPatternTermEx; import appeng.container.slot.SlotFake; +import com.github.vfyjxf.nee.nei.NEECraftingHandler; import com.github.vfyjxf.nee.network.NEENetworkHandler; import com.github.vfyjxf.nee.network.packet.PacketStackCountChange; import com.github.vfyjxf.nee.utils.GuiUtils; @@ -59,11 +61,10 @@ public class NotEnoughEnergistics { if (event.phase == TickEvent.Phase.START) { Minecraft mc = Minecraft.getMinecraft(); int i = Mouse.getDWheel(); - if (i != 0 && mc.currentScreen instanceof GuiPatternTerm) { - GuiPatternTerm guiPatternTerm = (GuiPatternTerm) mc.currentScreen; - int x = Mouse.getEventX() * guiPatternTerm.width / mc.displayWidth; - int y = guiPatternTerm.height - Mouse.getEventY() * guiPatternTerm.height / mc.displayHeight - 1; - Slot currentSlot = GuiUtils.getSlotUnderMouse(guiPatternTerm, x, y); + if (i != 0 && mc.currentScreen instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(mc.currentScreen)) { + int x = Mouse.getEventX() * mc.currentScreen.width / mc.displayWidth; + int y = mc.currentScreen.height - Mouse.getEventY() * mc.currentScreen.height / mc.displayHeight - 1; + Slot currentSlot = GuiUtils.getSlotUnderMouse((GuiContainer) mc.currentScreen, x, y); if (currentSlot instanceof SlotFake && currentSlot.getHasStack()) { int changeCount = GuiContainer.isCtrlKeyDown() ? i / 60 : i / 120; NEENetworkHandler.getInstance().sendToServer(new PacketStackCountChange(currentSlot.slotNumber, changeCount)); diff --git a/src/main/java/com/github/vfyjxf/nee/network/packet/PacketStackCountChange.java b/src/main/java/com/github/vfyjxf/nee/network/packet/PacketStackCountChange.java index 5cdcebe..069b990 100644 --- a/src/main/java/com/github/vfyjxf/nee/network/packet/PacketStackCountChange.java +++ b/src/main/java/com/github/vfyjxf/nee/network/packet/PacketStackCountChange.java @@ -1,6 +1,7 @@ package com.github.vfyjxf.nee.network.packet; import appeng.container.implementations.ContainerPatternTerm; +import com.github.vfyjxf.nee.utils.GuiUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; @@ -50,16 +51,16 @@ public class PacketStackCountChange implements IMessage, IMessageHandler 0) { - if (currentSlot.getStack().stackSize == currentSlot.getStack().getMaxStackSize()) { + if (currentSlot.getStack().stackSize >= currentSlot.getStack().getMaxStackSize()) { break; } currentSlot.getStack().stackSize = (currentSlot.getStack().stackSize + 1); } else { - if (currentSlot.getStack().stackSize - 1 == 0) { + if (currentSlot.getStack().stackSize - 1 <= 0) { break; } currentSlot.getStack().stackSize = currentSlot.getStack().stackSize - 1; diff --git a/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java b/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java index c932e12..278b6fb 100644 --- a/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java +++ b/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java @@ -2,7 +2,9 @@ package com.github.vfyjxf.nee.utils; import appeng.client.gui.AEBaseGui; import cpw.mods.fml.relauncher.ReflectionHelper; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import java.lang.reflect.InvocationTargetException; @@ -15,7 +17,7 @@ public class GuiUtils { public static Slot getSlotUnderMouse(GuiContainer guiContainer, int mouseX, int mouseY) { Method getSlotMethod = ReflectionHelper.findMethod(AEBaseGui.class, (AEBaseGui) guiContainer, new String[]{"getSlot"}, int.class, int.class); try { - return (Slot) getSlotMethod.invoke(guiContainer,mouseX,mouseY); + return (Slot) getSlotMethod.invoke(guiContainer, mouseX, mouseY); } catch (IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } @@ -23,5 +25,22 @@ public class GuiUtils { return null; } + public static boolean isPatternTermExGui(GuiScreen container) { + try { + Class patternTermExClz = Class.forName("appeng.client.gui.implementations.GuiPatternTermEx"); + return patternTermExClz.isInstance(container); + } catch (ClassNotFoundException e) { + return false; + } + } + + public static boolean isPatternTermExContainer(Container container){ + try { + Class patternTermExClz = Class.forName("appeng.container.implementations.ContainerPatternTermEx"); + return patternTermExClz.isInstance(container); + } catch (ClassNotFoundException e) { + return false; + } + } }