ContentTweaker

ContentTweaker

27M Downloads

onItemUpdate to work on item directly.

jelaw21 opened this issue ยท 0 comments

commented

I am trying to update an items nbt while it's in a player's inventory. Here's the code:
investment.onItemUpdate = function(itemStack, world, owner, slot, isSelected) { if(world.getWorldTime()%20 == 0){ var total = itemStack.tag.Total as int; print("Old Tag: " + total); total = total + 1; print("Tag increase: " + total); itemStack.updateTag({Total: total}); print("New Tag: " + itemStack.tag.Total); } return; };

The updateTag does not update the nbt of the item. This issue was suggested by kindlich on Discord:

Ah, that may be something that an issue could be created for at ContentTweaker's issue tracker.

@SkySom [ContentTweaker]
MutableItemStack only adds growth, shrink, damage and setCount as methods that actually affect the item.
Maybe we should override them to work on the item directly (or remove MCItemStack as parent and implement IMutableItemStack and IItemStack directly)?