BananaPuncher714 / NBTEditor

A single class NBT editor for items, skulls, mobs, and tile entities
MIT License
136 stars 30 forks source link

Issue when re-setting values #18

Closed LuisHNovais closed 3 years ago

LuisHNovais commented 3 years ago

Hello, I have this code and, the first set it's ok. But, when I try to re-set, it doesn't set anything.

First, I have this one, that happens ok:

        // CREATE YOUR OWN COMPOUND AND SET THE VALUES
        NBTEditor.NBTCompound properties = NBTEditor.getEmptyNBTCompound();
        properties.set("sim", "ySpawnersV2");
        properties.set(p.getName(), "Dono");
        properties.set(toStack, "Stack");
        properties.set(0, "Drop");
        properties.set(Lists.newArrayList("").toString(), "Amigos");
        properties.set(Lists.newArrayList("").toString(), "Remover");
        properties.set(Lists.newArrayList("").toString(), "Matar");
        properties.set(Lists.newArrayList("").toString(), "Vender");

        // SET THE OWN COMPOUND ON THE SPAWNDATA
        spawnData.set(properties, "SpawnData");

        // SET THE SPAWNDATA ON BLOCK
        NBTEditor.set(block, spawnData);

And, I have this another code, that doesn't work:

public static void setString(Block block, String data, String value){
        NBTEditor.NBTCompound compound = NBTEditor.getNBTCompound(block, "SpawnData");
        compound.set(value, data);
        NBTEditor.set(block, compound);
}
BananaPuncher714 commented 3 years ago

What version of spigot are you using? Also, what type of block are you trying to modify? It's not possible to add custom NBT tags on blocks or entities.

LuisHNovais commented 3 years ago

I'm working on 1.8.8, and trying to modify a mob_spawner. When I set the tag for the first time, it works. But when I try to edit, example: in the first set I've put Owner = "yChusy", when I try to edit the Owner to "Banana", it doesn't work.

BananaPuncher714 commented 3 years ago

When you set the block's compound back in your setString method, it needs to be NBTEditor.set( block, compound, "SpawnData" ); since you fetched it previously with NBTEditor.getNBTCompound( block, "SpawnData" ).

LuisHNovais commented 3 years ago

I'll try, give me a minute.

LuisHNovais commented 3 years ago

Works perfectly, thank you