Topic category: Help with Minecraft modding (Java Edition)
In my mod, I am making a container of magic energy as an item, called a magic battery. I will have many wands and such that will use this magic battery's energy from the user's inventory. I have come across a problem: I cannot directly set an NBT tag on an item from the player's inventory, only a copy of such item. I have thought of a workaround, in which I use a custom return-type procedure that uses an itemstack variable that I set to the already-existing magic battery. I apply changes to the magic level of the variable via NBT tags, then replace the existing battery with the variable. My problem with that is that I can't specify the slot the new battery is put in, so it just places it in the player's next available slot.
Huh? This worked for me...?
It just updates the NBT doesn't return a copy or anything
friyes...
What trigger is this procedure under?
rightclick with item? or do you mean category? I just search "data"
The problem is that I use a right-click-triggered procedure for a wand, then must change NBT data on a different item.
Okay, you should be able to change Provided Itemstack to that then...
I can create an itemstack variable and set it to a copy of the item from a certain slot (I have a method to find which slot the magic battery is in), then set an NBT variable on the variable. After that, I replace the old magic battery with the variable, but because there is no way to specify the slot that the variable goes in, it moves the battery to the next available slot. This annoyingly results in the magic battery appearing in the player's hotbar sometimes after using any wand.