Jump to content

Daedalus

Members
  • Posts

    2
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Daedalus's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Wow, forgot the error... Sorry... Yes, it's a NullPointerException, and I feel more like an idiot because checking if it was null or not fixed that issue, and then it wasn't counting which I fixed by changing: if (cycledStack.getItem().equals(heldStack)) To: if (cycledStack.getItem().equals(heldStack.getItem())) Thank you!
  2. I've been at this for a while now, and I try to not ask for help usually, but this time I'm at an impasse. I've created the command "count" which I want to get the item that the player is currently holding, then count the amount of that item in the players inventory, then send the player a message with the amount of that item. ItemStack heldStack = player.inventory.getCurrentItem(); if (heldStack != null) { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack cycledStack = player.inventory.getStackInSlot(i); if (cycledStack.getItem().equals(heldStack)) { itemCount = itemCount + cycledStack.stackSize; } } } I'm still fairly new to Java, so I'm assuming it's some stupid mistake that I somehow made. I don't want to be spoonfed code, I want to learn, so if you guys could help me out by pointing me in the right direction, that would be awesome. I apologize if I've forgotten anything in this post, please let me know if I have. Thanks!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.