TheCrafter4000 Posted December 23, 2015 Share Posted December 23, 2015 Hello, I just want to send a message to a player if a key is pressed, but, when I press the key nothing happends. My Event class: import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiChat; import net.minecraft.client.settings.GameSettings; import net.minecraft.util.ChatComponentText; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class KeyPressEvents { @SideOnly(Side.CLIENT) @SubscribeEvent(receiveCanceled=true) public void onKeyInput( KeyInputEvent event ) { System.out.println( "called" ); if( Minecraft.getMinecraft().gameSettings.keyBindInventory.isPressed() ) if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( "Pressed" ) ); } } I registered it at the FMLCommonHandler's EventBus FMLCommonHandler.instance().bus().register( new KeyPressEvents() ); The System.out.println( "called" ); is never showen Quote Sorry if there are mistakes in my english Link to comment Share on other sites More sharing options...
Filipsi Posted December 23, 2015 Share Posted December 23, 2015 Where do you register your event? KeyInputEvent is fired on client side, so it should be registered in your client proxy on init. Also, it would probably be a good idea to mark KeyPressEvents class as Client-Side only if you are using it only for KeyInput handling. As far as I know, there is no problem with your code. Tested it in 1.7.10 and worked fine. Quote Link to comment Share on other sites More sharing options...
TheCrafter4000 Posted December 23, 2015 Author Share Posted December 23, 2015 Thanks, registered it on both sides Quote Sorry if there are mistakes in my english Link to comment Share on other sites More sharing options...
Recommended Posts
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.