diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/torui/coflsky/EventRegistry.java | 61 |
1 files changed, 52 insertions, 9 deletions
diff --git a/src/main/java/de/torui/coflsky/EventRegistry.java b/src/main/java/de/torui/coflsky/EventRegistry.java index f7d708c..3a629a3 100644 --- a/src/main/java/de/torui/coflsky/EventRegistry.java +++ b/src/main/java/de/torui/coflsky/EventRegistry.java @@ -7,21 +7,19 @@ import de.torui.coflsky.commands.CommandType; import de.torui.coflsky.commands.JsonStringCommand; import de.torui.coflsky.network.WSClient; import net.minecraft.client.Minecraft; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.gui.MinecraftServerGui; -import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; -import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; -import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent; -import net.minecraftforge.fml.common.network.FMLNetworkEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.fml.server.FMLServerHandler; public class EventRegistry{ @@ -62,7 +60,6 @@ public class EventRegistry{ public void onEvent(KeyInputEvent event) { if(CoflSky.keyBindings[0].isPressed()) { - if(WSCommandHandler.lastOnClickEvent != null) { String command = WSCommandHandler.lastOnClickEvent; @@ -75,6 +72,52 @@ public class EventRegistry{ } } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void DrawOntoGUI(RenderGameOverlayEvent rgoe) { + + if(rgoe.type == ElementType.CROSSHAIRS) { + Minecraft mc = Minecraft.getMinecraft(); + mc.ingameGUI.drawString(Minecraft.getMinecraft().fontRendererObj, "Hello World", 0, 0, Integer.MAX_VALUE); + } + + //.currentScreen. + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void OnGuiOpen(GuiScreenEvent.KeyboardInputEvent goe) { + + + if (goe.gui instanceof GuiChest) { // verify that it's really a chest + ContainerChest chest = (ContainerChest)Minecraft.getMinecraft().thePlayer.openContainer; // it's now safe to cast + IInventory inv = chest.getLowerChestInventory(); + if (!inv.hasCustomName()) { // verify that the chest actually has a custom name + String chestName = inv.getName(); + System.out.println("Opened chest with custo name " + chestName); + } + else { + System.out.println("Opened regular chest"); + } + } + + + } + + /*try { + ItemStack stack = ((GuiChest) Minecraft.getMinecraft().currentScreen).getSlotUnderMouse().getStack(); + + System.out.println("Hovering over item: Pre " + stack.getDisplayName()); + stack.setStackDisplayName("Coflll"); + + System.out.println("Hovering over item: " + stack.getDisplayName()); + } catch(ClassCastException e) { + e.printStackTrace(); + }catch(NullPointerException e) { + + }*/ + } /*@SubscribeEvent public void OnSomething(FMLNetworkEvent.ClientConnectedToServerEvent event) { System.out.println("Client connect to server from network"); |