Jump to content

[1.8] KeyBinding Help [SOLVED]


JoelGodOfWar

Recommended Posts

So far all the tutorials i've found are for 1.7.10, and i can get the keybind to show up in the controls area of settings. But when i press the associated key nothing happens, until i quit the game, then a flood of msgs show up. Also the drawString doesn't seem to happen at all.

import net.minecraft.client.Minecraft;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
public class KeyInputHandler {
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
  if(KeyBindings.openGUI.isPressed()){
  mc.fontRendererObj.drawString("Z Pressed", 2, 20, 0xffffff);
  System.out.println("KEY Z");
  
  //OPEN GUI
   
  }
}
protected static Minecraft mc = Minecraft.getMinecraft();
}

 

I must be missing something. Also how do i enable/disable a class when the key is pressed?

Link to comment
Share on other sites

Well, obviously. DrawString is drawing method, you can't just call it anywhere.

If you want to have message in Chat then you do: Minecraft.getMinecraft().thePlayer.addChatMessage(message); for client.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.