Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Forging a Minecraft mod

Basic Minecraft modding with Minecraft Forge

boolean itemInHand(int ID)

  • 2013-08-02 14:48:52
    Im looking for something like that.... i was checking the EntityPlayer class but i cant find anything like that...

    i need a method that tells me if a player is holding X item in the hand in that moment and returns a boolean if possible...
  • 2013-08-02 15:43:52
    EntityPlayer have this method getHeldItem() and returns an Itemstack of the item the player is holding if any.

    Simply compare it to the X item to get the result

    boolean state = (player.getHeldItem() != null && player.getHeldItem().getItem() == Items.wand)
  • 2013-08-03 10:45:08
    thanks that help me a lot
  • 2013-08-03 18:52:12
    You'r welcome :P
  • Log in or sign up to reply to this thread