Posted December 23, 20159 yr 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 Sorry if there are mistakes in my english
December 23, 20159 yr 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.
December 23, 20159 yr Author Thanks, registered it on both sides Sorry if there are mistakes in my english
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.