Closed Master-chan closed 10 years ago
you're right. I'm already working on a new API
Sorry for bothering, but can you explain how to save edited tag back to NBTContainerEntity? The setTag method seems to write only in root compound, while I need to write modified player attributes.
You need to read root tag, then modify it's attributes, and save tag back to container. No other way, because the tags are read and written fully
I'm reading tag like this:
NBTContainerEntity con = new NBTContainerEntity(entity);
NBTTagCompound compound = (NBTTagCompound) con.getTag();
NBTTagList attributes = compound.getList("Attributes");
compound = (NBTTagCompound) attributes.get(1);
NBTTagDouble kbResist = (NBTTagDouble) compound.get("Base");
But I don't understand how to save my NBTTagDouble after editing.
NBTContainerEntity con = new NBTContainerEntity(entity);
NBTTagCompound compound = (NBTTagCompound) con.getTag();
NBTTagList attributes = compound.getList("Attributes");
NBTTagCompound attr = (NBTTagCompound) attributes.get(1);
// read value
NBTTagDouble kbResist = (NBTTagDouble) attr.get("Base");
// set new value
attr.put("Base",(double) newKbResist )
// and save
con.setTag(compound) // compound has been changed
it should work
Thank you very much, i was puzzling over this for 2 hours :+1:
This method looking wrong [NBTTagList.java:122]