diff options
author | Florian Rinke <develop@torui.de> | 2021-11-05 22:04:40 +0100 |
---|---|---|
committer | Florian Rinke <develop@torui.de> | 2021-11-05 22:04:40 +0100 |
commit | 15937203b5814a1470625d9195c5f4224b7fe836 (patch) | |
tree | 724de52ab588134ddb9afb7b82f53eeb03a9bbd5 | |
parent | 39a061b57e38667987a4e38df71b5d8030222c1b (diff) | |
download | COFL-15937203b5814a1470625d9195c5f4224b7fe836.tar.gz COFL-15937203b5814a1470625d9195c5f4224b7fe836.tar.bz2 COFL-15937203b5814a1470625d9195c5f4224b7fe836.zip |
.
-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"); |