Posted February 9, 201510 yr I'm making a mod for removing the most recent line in chat from the client, what I don't know is: 1 where to execute the full command for the key binding 2 what the code is to remove the most recent line of code
February 9, 201510 yr Author Sorry but you can't do that. What the hell dude... of course he can. Take a look at GuiNewChat, it has methods to remove from text. As for KeyBindings... there are enough tutorials. ok, thanks, I'll try it
February 9, 201510 yr Author having trouble with the GuiNewChat, It is saying that I'm making a static reference to a non static method Here is how my key input event handler is set up right now public class KeyInputEventHandler { private static Key getPressedKeyBinding(){ if (Keybindings.clear.isPressed()){ return Key.CLEAR; }else{ return null; } } @SubscribeEvent public void handleKeyInputEvent(InputEvent.KeyInputEvent event){ LogHelper.info(getPressedKeyBinding()); if(Keybindings.clear.isPressed()){ GuiNewChat.refreshChat(); } } }
February 9, 201510 yr Author ok, how am I supposed to set up the instance? I looked at the class where the declaration is and I am confused, I tried multiple ways of setting up the instance but none seem to work
February 9, 201510 yr Author Make a search in your IDE where that class is used. You will see fields where it's stored in. Get access that way, you don't make an instance yourself. that did help and I found a better method for what I want but after I implemented the method it needed, it still said that I am implementing a static reference, the declaration for this method is: public void deleteChatLine(int p_146242_1_) { Iterator iterator = this.field_146253_i.iterator(); ChatLine chatline; while (iterator.hasNext()) { chatline = (ChatLine)iterator.next(); if (chatline.getChatLineID() == p_146242_1_) { iterator.remove(); } } and I have my code set up like this: private static Key getPressedKeyBinding(){ if (Keybindings.clear.isPressed()){ return Key.CLEAR; }else{ return null; } } @SubscribeEvent public void handleKeyInputEvent(InputEvent.KeyInputEvent event){ LogHelper.info(getPressedKeyBinding()); if(Keybindings.clear.isPressed()){ GuiNewChat.deleteChatLine(1); } } }
February 10, 201510 yr Exactly, you are attempting to call a method statically when the method isn't static. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
February 10, 201510 yr Author Exactly, you are attempting to call a method statically when the method isn't static. ok, then how do I fix it?
February 10, 201510 yr If you don't know how to not call a method statically when the method isn't static, I highly suggest you learn some basic Java first, and then come back to modding. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
February 12, 201510 yr Author Well I figured out how to implement it non-statically, but now I'm having trouble checking if its the correct keybinding and why it's not being called code: private static Key getPressedKeyBinding(){ if (Keybindings.clear.isPressed()){ return Key.CLEAR; }else{ return null; } } public int field_146253_i = 1; public int p_146242_1_ = 1; void deleteChatLine(){ } @SubscribeEvent public void handleKeyInputEvent(InputEvent.KeyInputEvent event){ LogHelper.debug(getPressedKeyBinding()); if(getPressedKeyBinding() != null){ deleteChatLine(); }else{ } } }
February 13, 201510 yr Author ok, realized that the if statement wasn't firing, so after I changed it, it crashed me, am I doing something wrong in the code? package com.crazykid080.ClearChat.client.handler; import net.minecraft.client.gui.GuiNewChat; import com.crazykid080.ClearChat.client.settings.Keybindings; import com.crazykid080.ClearChat.reference.Key; import com.crazykid080.ClearChat.utility.LogHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; public class KeyInputEventHandler { private static Key getPressedKeyBinding(){ if (Keybindings.clear.isPressed()){ return Key.CLEAR; }else{ return null; } } public int field_146253_i = 1; public int p_146242_1_ = 1; void deleteChatLine(){ } void clearChatMessages(){ } @SubscribeEvent public void handleKeyInputEvent(InputEvent.KeyInputEvent event){ LogHelper.info(getPressedKeyBinding()); if(getPressedKeyBinding().equals(Key.CLEAR)){ LogHelper.fatal("IT WORKED"); //deleteChatLine(); //clearChatMessages(); }else{ } } }
February 13, 201510 yr Author removed anything not an error report/stack trace [16:31:13] [Client thread/FATAL]: Unreported exception thrown! java.lang.NullPointerException at com.crazykid080.ClearChat.client.handler.KeyInputEventHandler.handleKeyInputEvent(KeyInputEventHandler.java:36) ~[KeyInputEventHandler.class:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_KeyInputEventHandler_handleKeyInputEvent_KeyInputEvent.invoke(.dynamic) ~[?:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) ~[ASMEventHandler.class:?] at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) ~[EventBus.class:?] at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540) ~[FMLCommonHandler.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1953) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_31] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?] at GradleStart.main(GradleStart.java:45) [start/:?] [16:31:13] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ---- // Who set us up the TNT? Time: 2/12/15 4:31 PM Description: Unexpected error java.lang.NullPointerException: Unexpected error at com.crazykid080.ClearChat.client.handler.KeyInputEventHandler.handleKeyInputEvent(KeyInputEventHandler.java:36) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_KeyInputEventHandler_handleKeyInputEvent_KeyInputEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1953) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) at net.minecraft.client.Minecraft.run(Minecraft.java:951) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) at GradleStart.main(GradleStart.java:45) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.crazykid080.ClearChat.client.handler.KeyInputEventHandler.handleKeyInputEvent(KeyInputEventHandler.java:36) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_KeyInputEventHandler_handleKeyInputEvent_KeyInputEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540) Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2555) at net.minecraft.client.Minecraft.run(Minecraft.java:980) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) at GradleStart.main(GradleStart.java:45)
February 13, 201510 yr removed anything not an error report/stack trace [16:31:13] [Client thread/FATAL]: Unreported exception thrown! java.lang.NullPointerException at com.crazykid080.ClearChat.client.handler.KeyInputEventHandler.handleKeyInputEvent(KeyInputEventHandler.java:36) ~[KeyInputEventHandler.class:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_KeyInputEventHandler_handleKeyInputEvent_KeyInputEvent.invoke(.dynamic) ~[?:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) ~[ASMEventHandler.class:?] at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) ~[EventBus.class:?] at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540) ~[FMLCommonHandler.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1953) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_31] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?] at GradleStart.main(GradleStart.java:45) [start/:?] [16:31:13] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ---- // Who set us up the TNT? Time: 2/12/15 4:31 PM Description: Unexpected error java.lang.NullPointerException: Unexpected error at com.crazykid080.ClearChat.client.handler.KeyInputEventHandler.handleKeyInputEvent(KeyInputEventHandler.java:36) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_KeyInputEventHandler_handleKeyInputEvent_KeyInputEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1953) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) at net.minecraft.client.Minecraft.run(Minecraft.java:951) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) at GradleStart.main(GradleStart.java:45) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.crazykid080.ClearChat.client.handler.KeyInputEventHandler.handleKeyInputEvent(KeyInputEventHandler.java:36) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_KeyInputEventHandler_handleKeyInputEvent_KeyInputEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540) Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2555) at net.minecraft.client.Minecraft.run(Minecraft.java:980) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) at GradleStart.main(GradleStart.java:45) You never did a nullpointer check seeing whether there was not any buttons being pressed. I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!
February 13, 201510 yr Author well I have fixed it, but now I need to find out how to get the code working I have it like this package com.crazykid080.ClearChat.client.handler; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.GuiNewChat; import com.crazykid080.ClearChat.client.settings.Keybindings; import com.crazykid080.ClearChat.reference.Key; import com.crazykid080.ClearChat.utility.LogHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; public class KeyInputEventHandler { private static Key getPressedKeyBinding(){ if (Keybindings.clear.isPressed()){ return Key.CLEAR; }else{ return null; } } int field_146253_i = 1; int p_146242_1_ = 1; @SubscribeEvent public void handleKeyInputEvent(InputEvent.KeyInputEvent event){ Key pressedKey = getPressedKeyBinding(); LogHelper.info(pressedKey); if (pressedKey != null){ if(pressedKey.equals(Key.CLEAR)){ LogHelper.fatal("IT WORKED"); GuiIngame gui = getChatGUI(); GuiNewChat newChat = gui.getChatGUI(); newChat.deleteChatLine(p_146242_1_); }else{ } } } private GuiIngame getChatGUI() { return null; } }
February 13, 201510 yr Author removed anything not an error report/stack trace [16:31:13] [Client thread/FATAL]: Unreported exception thrown! java.lang.NullPointerException at com.crazykid080.ClearChat.client.handler.KeyInputEventHandler.handleKeyInputEvent(KeyInputEventHandler.java:36) ~[KeyInputEventHandler.class:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_KeyInputEventHandler_handleKeyInputEvent_KeyInputEvent.invoke(.dynamic) ~[?:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) ~[ASMEventHandler.class:?] at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) ~[EventBus.class:?] at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540) ~[FMLCommonHandler.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1953) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_31] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_31] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?] at GradleStart.main(GradleStart.java:45) [start/:?] [16:31:13] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ---- // Who set us up the TNT? Time: 2/12/15 4:31 PM Description: Unexpected error java.lang.NullPointerException: Unexpected error at com.crazykid080.ClearChat.client.handler.KeyInputEventHandler.handleKeyInputEvent(KeyInputEventHandler.java:36) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_KeyInputEventHandler_handleKeyInputEvent_KeyInputEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1953) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) at net.minecraft.client.Minecraft.run(Minecraft.java:951) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) at GradleStart.main(GradleStart.java:45) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.crazykid080.ClearChat.client.handler.KeyInputEventHandler.handleKeyInputEvent(KeyInputEventHandler.java:36) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_KeyInputEventHandler_handleKeyInputEvent_KeyInputEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540) Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2555) at net.minecraft.client.Minecraft.run(Minecraft.java:980) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) at GradleStart.main(GradleStart.java:45) You never did a nullpointer check seeing whether there was not any buttons being pressed. my dad helped me with that
February 15, 201510 yr Author I still need help with getting the command to fire, there is no errors being shown package com.crazykid080.ClearChat.client.handler; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.GuiNewChat; import com.crazykid080.ClearChat.client.settings.Keybindings; import com.crazykid080.ClearChat.reference.Key; import com.crazykid080.ClearChat.utility.LogHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; public class KeyInputEventHandler { private static Key getPressedKeyBinding(){ if (Keybindings.clear.isPressed()){ return Key.CLEAR; }else{ return null; } } @SubscribeEvent public void handleKeyInputEvent(InputEvent.KeyInputEvent event){ Key pressedKey = getPressedKeyBinding(); LogHelper.debug(pressedKey); if (pressedKey != null){ if(pressedKey.equals(Key.CLEAR)){ deleteChatLine(1); LogHelper.info("fired"); }else{ } } } private void deleteChatLine(int p_146242_1_2) { } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.