mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-11-27 23:33:13 +00:00
add mouse wheel plugin
This commit is contained in:
1 parent
dfc5185030
commit
288a8531af
7 files changed
+147
-6
No files matched your search
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user