diff --git a/README.md b/README.md index b18f50c..d12dc66 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Not Enough Energistics -[![Downloads](https://cf.way2muchnoise.eu/full_515565_downloads.svg)]([Not Enough Energistics - Mods - Minecraft - CurseForge](https://www.curseforge.com/minecraft/mc-mods/not-enough-energistics)) ![MCVsrsion](https://cf.way2muchnoise.eu/versions/515565.svg) +[![Downloads](https://cf.way2muchnoise.eu/full_515565_downloads.svg)](https://www.curseforge.com/minecraft/mc-mods/not-enough-energistics) ![MCVsrsion](https://cf.way2muchnoise.eu/versions/515565.svg) ---- @@ -23,6 +23,7 @@ This mod removes that functionality and allows the player to use NEI's transfer - Support Processing Pattern Terminal(16 -> 4 mode). - Allow you to add item blackList and item priority list, if item in them, it will not be transferred / transfer it first.(use /nee RecipeProcessor to get RecipeProcessor and identifier in log) - Allow you to add mod priority list,if the mod's has this item,it will be use first. +- You can use the mouse wheel to change the Pattern item input/output amount. ## Compatible Modslist as followed: diff --git a/READNE_CN.md b/READNE_CN.md index 487d81f..bdde955 100644 --- a/READNE_CN.md +++ b/READNE_CN.md @@ -1,6 +1,6 @@ # Not Enough Energistics -[![Downloads](https://cf.way2muchnoise.eu/full_515565_downloads.svg)]([Not Enough Energistics - Mods - Minecraft - CurseForge](https://www.curseforge.com/minecraft/mc-mods/not-enough-energistics)) ![MCVsrsion](https://cf.way2muchnoise.eu/versions/515565.svg) +[![Downloads](https://cf.way2muchnoise.eu/full_515565_downloads.svg)](https://www.curseforge.com/minecraft/mc-mods/not-enough-energistics) ![MCVsrsion](https://cf.way2muchnoise.eu/versions/515565.svg) ---- @@ -18,6 +18,7 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min - 支持增广样板终端(16 -> 4模式) - 允许你设置转换黑名单和转换优先名单,如对应物品在里面,那么他们将不会被转移/优先被转移 - 允许你设置mod优先级列表,优先使用该mod的物品 +- 你可以使用鼠标滚轮来修改样板的输入/输出数量 ## 当前支持的Mod列表: diff --git a/gradle.properties b/gradle.properties index a95fb35..37870b4 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.7 +mod_version=1.2.8 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 eb38132..f7ad40e 100644 --- a/src/main/java/com/github/vfyjxf/nee/NotEnoughEnergistics.java +++ b/src/main/java/com/github/vfyjxf/nee/NotEnoughEnergistics.java @@ -1,12 +1,25 @@ package com.github.vfyjxf.nee; +import appeng.client.gui.implementations.GuiPatternTerm; +import appeng.container.slot.SlotFake; import com.github.vfyjxf.nee.network.NEENetworkHandler; +import com.github.vfyjxf.nee.network.packet.PacketStackCountChange; +import com.github.vfyjxf.nee.utils.GuiUtils; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; import net.minecraft.launchwrapper.Launch; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Mouse; import java.io.File; @@ -23,15 +36,40 @@ public class NotEnoughEnergistics { public static final String DEPENDENCIES = "required-after:NotEnoughItems;required-after:appliedenergistics2"; public static final Logger logger = LogManager.getLogger("NotEnoughEnergistics"); - @Mod.EventHandler + @EventHandler public void preInit(FMLPreInitializationEvent e) { NEENetworkHandler.init(); NEEConfig.loadConfig(new File(Launch.minecraftHome, "config/NotEnoughEnergistics.cfg")); } - @Mod.EventHandler - private void serverStarting(FMLServerStartingEvent event) { + @EventHandler + public void init(FMLInitializationEvent event) { + if (FMLCommonHandler.instance().getSide().isClient()) { + FMLCommonHandler.instance().bus().register(this); + } + } + + @EventHandler + public void serverStarting(FMLServerStartingEvent event) { event.registerServerCommand(new NEECommands()); } + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent event) { + 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 (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/NEENetworkHandler.java b/src/main/java/com/github/vfyjxf/nee/network/NEENetworkHandler.java index e66bca1..b55d64c 100644 --- a/src/main/java/com/github/vfyjxf/nee/network/NEENetworkHandler.java +++ b/src/main/java/com/github/vfyjxf/nee/network/NEENetworkHandler.java @@ -4,6 +4,7 @@ import com.github.vfyjxf.nee.NotEnoughEnergistics; import com.github.vfyjxf.nee.network.packet.PacketArcaneRecipe; import com.github.vfyjxf.nee.network.packet.PacketExtremeRecipe; import com.github.vfyjxf.nee.network.packet.PacketNEIPatternRecipe; +import com.github.vfyjxf.nee.network.packet.PacketStackCountChange; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; @@ -19,6 +20,7 @@ public class NEENetworkHandler { INSTANCE.registerMessage(PacketNEIPatternRecipe.class, PacketNEIPatternRecipe.class, 0, Side.SERVER); INSTANCE.registerMessage(PacketArcaneRecipe.class, PacketArcaneRecipe.class, 1, Side.SERVER); INSTANCE.registerMessage(PacketExtremeRecipe.class, PacketExtremeRecipe.class, 2, Side.SERVER); + INSTANCE.registerMessage(PacketStackCountChange.class, PacketStackCountChange.class, 3, Side.SERVER); } } \ No newline at end of file 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 new file mode 100644 index 0000000..5cdcebe --- /dev/null +++ b/src/main/java/com/github/vfyjxf/nee/network/packet/PacketStackCountChange.java @@ -0,0 +1,72 @@ +package com.github.vfyjxf.nee.network.packet; + +import appeng.container.implementations.ContainerPatternTerm; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; + +/** + * @author vfyjxf + */ +public class PacketStackCountChange implements IMessage, IMessageHandler { + + private int slotIndex; + private int changeCount; + + public int getSlotIndex() { + return slotIndex; + } + + public int getChangeCount() { + return changeCount; + } + + public PacketStackCountChange() { + + } + + public PacketStackCountChange(int slotIndex, int changeCount) { + this.slotIndex = slotIndex; + this.changeCount = changeCount; + } + + @Override + public void fromBytes(ByteBuf buf) { + this.slotIndex = buf.readInt(); + this.changeCount = buf.readInt(); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(this.slotIndex); + buf.writeInt(this.changeCount); + } + + @Override + public IMessage onMessage(PacketStackCountChange message, MessageContext ctx) { + EntityPlayerMP player = ctx.getServerHandler().playerEntity; + Container container = player.openContainer; + if (container instanceof ContainerPatternTerm && !((ContainerPatternTerm) container).isCraftingMode()) { + Slot currentSlot = container.getSlot(message.getSlotIndex()); + for (int i = 0; i < Math.abs(message.getChangeCount()); i++) { + if (message.getChangeCount() > 0) { + if (currentSlot.getStack().stackSize == currentSlot.getStack().getMaxStackSize()) { + break; + } + currentSlot.getStack().stackSize = (currentSlot.getStack().stackSize + 1); + } else { + if (currentSlot.getStack().stackSize - 1 == 0) { + break; + } + currentSlot.getStack().stackSize = currentSlot.getStack().stackSize - 1; + } + + } + } + return null; + } +} diff --git a/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java b/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java new file mode 100644 index 0000000..c932e12 --- /dev/null +++ b/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java @@ -0,0 +1,27 @@ +package com.github.vfyjxf.nee.utils; + +import appeng.client.gui.AEBaseGui; +import cpw.mods.fml.relauncher.ReflectionHelper; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * @author vfyjxf + */ +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); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + + return null; + } + + +}