Procedure does not register Items with NBT Data

Started by Notchguy76 on

Topic category: Troubleshooting, bugs, and solutions

Last seen on 04:43, 7. Oct 2024
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Procedure does not register Items with NBT Data
Sun, 07/28/2024 - 09:00 (edited)

The "Has Event/target entity have in Inventory" Procedure does not seem to register Items with NBT Data, this includes Custom items that have been given Special NBT Data or Items such as Chests or Shulker Boxes that have items stored inside of them.

Given that the Item in my mod needs both the inventory check and NBT data at the same time is causing me issues, I am struggling to find a solution/workaround and would appreciate any recommendations. 

Edited by Notchguy76 on Sun, 07/28/2024 - 09:00
Contains procedure checks…
Sun, 07/28/2024 - 17:22

Contains procedure checks from vanilla Minecraft matches exact item with all of its data entries.

To check for specific item types only, you will need to iterate all items in inventory of player and check manually

Last seen on 04:43, 7. Oct 2024
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sounds good, thanks!
Mon, 07/29/2024 - 16:30

Sounds good, thanks!

Last seen on 04:43, 7. Oct 2024
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I just found a clever…
Mon, 07/29/2024 - 17:04

I just found a clever workaround, in case anyone else is having the same issue you can get the inventory check to work a lot more efficiently by having it check for a tag instead of just one item. To do this simply replace this code segment in your auto generated code:

.contains(new ItemStack(ModNameItems.ItemName.get())) : false)

replace it with:

.contains(ItemTags.create(new ResourceLocation("namespace:tag_name"))) : false)

You will also need to make sure the item that you want checked for is listed under the same tag used in the codeblock, as well a use Ctrl+W so that MCreator adds the required Imports.