Obtaining data from an item. (Tag, ID etc.)

Started by VegaOrionis on

Topic category: Help with MCreator software

Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Obtaining data from an item. (Tag, ID etc.)

Hello, I'd like to obtain specific item data, specifically the tag. Using the "/data entity" command, I can also see information about items in my inventory and their data. I'd like to obtain this data in MCreator for a specific item, but I don't know how to extract it. I've tried various combinations, but I must be doing something wrong... I'm not getting any feedback when testing. 


https://imgur.com/a/OcH5NfK

Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There are no errors. Simply…
Tue, 09/23/2025 - 12:24

There are no errors. Simply sending a message in-game doesn't happen. I also checked it by setting the "right-click on a block" option, and nothing happens either. I'm not familiar with custom codes or how to write them to make them work. I don't have enough knowledge in this area.

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
welp, you only need to get…
Tue, 09/23/2025 - 12:30

welp,

you only need to get the enchantments from books and the effects from potions, right?

try replacing the custom code snippet with,

EnchantedBookItem.getEnchantments(((LivingEntity)entity).getActiveItemStack())

and then hold an enchanted book

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
actually, what item did you…
Tue, 09/23/2025 - 12:32

actually, what item did you hold when you did it?

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay well at least you get…
Tue, 09/23/2025 - 12:53

Okay well at least you get something now..

try,

((LivingEntity)entity).getActiveItemStack().getEnchantmentTagList()

Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
No changes, same as before…
Tue, 09/23/2025 - 12:59

No changes, same as before. I don't know if it's the mCreator version or what's going on. Besides, how do you know how to write custom code? And how to address potions?

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay so, never try…
Tue, 09/23/2025 - 14:06

Okay so, never try programming anything to do with minecraft mods by proxy using purely javadocs lol

I set up a 2020.5 mcreator environment. (omg gradle takes so long in that version xd)

((LivingEntity)entity).getHeldItemMainhand().getTag()

this gets the data, finally x3..

 

You could probably actually just save that and just it to compare items, since the items you want to compare aren't stackable (potions and enchanted books)

Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks so much! And sorry…
Tue, 09/23/2025 - 14:17

Thanks so much! And sorry for taking up so much of your time.

And how should this be applied to another block, for example, the one you're currently opening? xD

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
it seems possible, i'm in…
Tue, 09/23/2025 - 15:43

it seems possible, i'm in the process of making a plugin for you. not like nbt edit blocks just getting items in a container.

can't promise anything though x3

Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Wow, it's amazing that you…
Tue, 09/23/2025 - 16:38

Wow, it's amazing that you can create plugins! I don't even know how to do it. You're very talented. I tested your plugin and unfortunately, it works too well, in that it provides information from the player's entire inventory and the opened block. I was looking for a way to refer more to a specific slot in the block being opened.
I have absolutely no idea what I'm doing, but I tried to write a custom procedure:

((LivingEntity)entity).getItemStack.containing(BlockPos((int) x, (int) y, (int) z), (int) (0))).getTag()((LivingEntity)entity).getItemStack(BlockPos((int) x, (int) y, (int) z), (int) (0))).getTag()
((LivingEntity)entity).getItemStack(BlockPos(entity.getX(), entity.getY(),entity.getY()), (int) (0))).getTag()

but it doesn't compile xD
 

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
:3 it's not actually super…
Tue, 09/23/2025 - 17:47

:3 it's not actually super hard if you know java.

Oh right I didn't actually test with any items in my inventory, just a chest with some items.
I think I fixed it though.

https://files.catbox.moe/062674.zip