Access/modify the forge capability NBT from an item stack
Charnuz opened this issue ยท 2 comments
Feature request description
The ability to get, modify and set the capability NBT an item stack has, using IData probably.
Feature request reason
For example: TerraFirmaCraft stores food creation time within the capability NBT, being able to carry that over through crafting would be good.
**Game Version
1.12
Isn't this already possible though
https://docs.blamejared.com/1.12/en/Vanilla/Items/IItemStack/#tag
If you're asking for capability support, I don't think that is going to be a thing, not in 1.12 anyway.
capabilities can be literally endless and there isn't a good way to expose that to scripts.
You can change the NBT of items very easily though, so as long as the capability is stored in the item's nbt, you could just change it there on craft? Not sure if that would work, depends on how mods do things
The capability NBT is stored in a separate compound NBT from tags, but is still accessible as "ForgeCaps" when the stack's NBT is serialized, whereas tags are stored as "tags." No need to get the actual capabilities that the stack has or interact with them, just the shared NBT that they use
This would be for cases where it is strictly stored within the capability NBT. Of course, this would only cover capabilities that use the ForgeCaps NBT but its better than nothing
Could do something like this to get the capability NBT from a stack:
public IData getXYZ() {
NBTTagCompound nbt = stack.serializeNBT().getCompoundTag("ForgeCaps");
return NBTConverter.from(nbt);
}