21 avr. 2015, 16:19

@‘sosoh’:

Merci ! 🙂 je crois avoir compris mais avec le code que tu vas me donner je pense que ça ce être plus explicit 🙂 Juste si j’ai bien compris si je veux enregistrer une string je dois la mettre dans une NBTTagString ?

Voilà :


@Override
public void saveNBTData(NBTTagCompound compound) {
NBTTagCompound properties = new NBTTagCompound();
properties.setDouble("Mana", this.mana);
properties.setDouble("MaxMana", this.maxMana);
properties.setString("spellRight", this.spellRight);
properties.setString("spellLeft", this.spellLeft);

if (this.spellsList != null) {
NBTTagList list = new NBTTagList();
for (String spell : this.spellsList) {
list.appendTag(new NBTTagString(spell));
}
properties.setTag("Spells", list);
}
compound.setTag(EXT_PROP_NAME, properties);
}

Pour mettre un String, il y a 2 méthodes :

  • Si c’est un NBTTagCompound : tonTagCompound.setString(key, value)
  • Si c’est un NBTTagList : tonTagList.appendTag(new NBTTagString(value))