Posted July 26, 20223 yr I want to detect when the player presses the arrow keys so that I can rotate a entity on my custom screen. I know how to rotate the entity but dont know how to detect when the player is pressing one of the keys.
July 26, 20223 yr @SubscribeEvent public void onKeyInputEvent(InputEvent.Key event) { if (Minecraft.getInstance().options.keyForward.isDown()) { // ... } } or if (Minecraft.getInstance().player.input.up) { // ... } Edited July 26, 20223 yr by Zergatul
July 26, 20223 yr Screen#keyPressed is the way to go in a custom Screen, take a look at this for the parameters
July 26, 20223 yr Author I looked at the parameters for keyPressed and got the keyCode but i dont know what to put for the other 2.
July 26, 20223 yr the second parameter is the "scanCode" and the third parameter is the "modifiers" ARG 1 keyCode ARG 2 scanCode ARG 3 modifiers
July 26, 20223 yr Author what is a scan code? what are the modifiers? there are both integers but other than that idk. where do i get the values for them from. Edited July 26, 20223 yr by awesomedude3595
July 26, 20223 yr You don't call the method yourself. You override the method in your Screen to trap the keys you want to process. See for example ConfirmScreen.keyPressed() or one of the other vanilla screens. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
July 26, 20223 yr Author yes i know but it ask for 3 parameters i only know what to enter for the first one.
July 26, 20223 yr 11 minutes ago, awesomedude3595 said: what is a scan code? https://github.com/MinecraftForge/MinecraftForge/blob/094200e687135df77096341e3d56860d96d08384/src/main/java/net/minecraftforge/client/event/ScreenEvent.java#L726-L734 11 minutes ago, awesomedude3595 said: what are the modifiers? https://github.com/MinecraftForge/MinecraftForge/blob/094200e687135df77096341e3d56860d96d08384/src/main/java/net/minecraftforge/client/event/ScreenEvent.java#L740-L750
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.