Way to store itemstack variable on a per-entity basis?

Started by MadAtNothing on

Topic category: Help with Minecraft modding (Java Edition)

Joined Mar 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Way to store itemstack variable on a per-entity basis?

Hello! I am rather new to Minecraft modding, but all has been going quite smoothly so far as I work on my first real mod.

 

However, I've run into a bit of a snag when creating a custom trading interface for one of my entities and am unsure how to proceed. I am generating my trades via loot tables, in order to allow for loot-table-specific functions randomized enchantments and (most importantly) custom explorer maps. 

 

This works wonderfully, except that I have no clue how to store itemstack data like this in the entity itself, to keep trades persistent rather than rolling a new one each time a trade occurs. Synced data seems to only support logic, number, or string variables, and none of these would really work to do what I need to do, afaik.

 

Is there a way to solve this? I've had to lock elements and work outside of the API before to get things functioning, so I'm open to using custom code, but with something like this I don't even know where I'd start.

Joined Mar 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ah, thank you! My main issue…
Sun, 03/30/2025 - 18:34

Ah, thank you! My main issue was that the entity already has an inventory that it is using for the trade GUI, but I realize now that you can probably just extend the inventory beyond the slots that the player is able to interact with :)

Joined Mar 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I still do wish there were…
Sun, 03/30/2025 - 18:36

I still do wish there were ways to store itemstack or entity variables using synced data. It would make things much more elegant and a lot easier to work with, especially when creating more complicated behaviors.