Posted February 1, 20169 yr I'm making a new mod where my first step is to make a GUI come up when a player shift-right-clicks on an EntityTameable with an open hand. This is my first time delving into key bindings and GUIs. This code @EventHandler public void init(FMLInitializationEvent event) { shift = new KeyBinding("key.shift", Keyboard.KEY_LSHIFT, "key.categories.pettransfer"); ClientRegistry.registerKeyBinding(shift); } @SubscribeEvent public void animalClicked(EntityInteractEvent event){ if (event.entityPlayer.worldObj.isRemote) { if (!event.entityPlayer.isUsingItem()) { if (event.target instanceof EntityTameable) { System.out.println("It works!!!!!!!!!!!"); event.entityPlayer.openGui(Base.instance, PetGUI.GUI_ID, event.entityPlayer.worldObj, (int)event.entityPlayer.posX, (int)event.entityPlayer.posY, (int)event.entityPlayer.posZ); } } } } Made it so that the player could not crouch or move down while flying. I haven't a clue how to do this correctly. I was unable to find a decent tutorial on this and had to copy some of my code from another forum thread.
February 1, 20169 yr I think a better way to do is, is by using no key registration at all. But check if the player is crouching when your EntityInteract event method is called. (event.entityPlayer.isCrouching(), ore something like that). Unless of course you really want to bind a specific key! Projects: Discontinued: - N2ConfigAPI - Meachanical Crafting Table Latest: - CollectionUtils Coöperations: - InGameConfigManager
February 1, 20169 yr Author event.entityPlayer.isSneaking is exactly what I was looking for. Thank you!
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.