20 avr. 2015, 21:30

J’ai fait ca, mais ca ne marche pas:

​@Override

public void saveNBTData(NBTTagCompound compound) 
    {

        NBTTagCompound properties = new NBTTagCompound();
        NBTTagList nbtlist = new NBTTagList();
        properties.setDouble("Mana", this.mana);
        properties.setDouble("MaxMana", this.maxMana);
        properties.setString("spellRight", this.spellRight);
        properties.setString("spellLeft", this.spellLeft);
        properties.setInteger("spellsListSize", this.spellsList.size());
        nbtlist.appendTag(properties);
        if(this.spellsList != null){
            for(String spell : this.spellsList)
            {
            NBTTagCompound nbttag = new NBTTagCompound();
            nbttag.setString("spellsList", spell);
                nbtlist.appendTag(nbttag);
            }
        }
        compound.setTag(EXT_PROP_NAME, nbtlist);
    }

@Override
public void loadNBTData(NBTTagCompound compound) 
{
NBTTagList nbtlist = (NBTTagList) compound.getTag(EXT_PROP_NAME);
NBTTagCompound properties = nbtlist.getCompoundTagAt(1);
this.mana = properties.getDouble("Mana");
this.maxMana = properties.getDouble("MaxMana");
this.spellRight = properties.getString("spellRight");
this.spellLeft = properties.getString("spellLeft");
int size = properties.getInteger("spellsListSize");
if(size > 0){
for(int i = 0; i < size; i++){
NBTTagCompound nbttag = nbtlist.getCompoundTagAt(i);
this.spellsList.add(i, nbttag.getString("spellsList"));
}
}
}