Multiple Item Detecting

Started by SackboyGamerYT on Mon, 11/14/2016 - 19:12

Topic category: Help with MCreator modding

Last seen on 10:15, 29. Mar 2017
Joined Sep 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Multiple Item Detecting
Mon, 11/14/2016 - 19:12

Hi Everyone! How are you lot today? :)

I have been making a Mod, and i need to make a Event that detects more than 1 of the same item.

but there is no option for that in Conditions.

does someone know a substitute to it?

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
I recommend you make a for
Mon, 11/14/2016 - 21:41

I recommend you make a for loop , that will iterate through players inventory and if it the item in the slot is equal to yours , use stackSize variable and check for the ItemStack size.

Something like:

for (ItemStack s : entity.inventory.mainInventory) {
        if (s != null && s.getItem() == YOUR_ITEM) {
           if(s.stackSize > 16){
            

         }
        }
    }

Last seen on 10:15, 29. Mar 2017
Joined Sep 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
RE:I recommend you make a for
Fri, 11/25/2016 - 14:52

@#1

where do you put that?