flinbein / PowerNBT

[MineCraft] Minecraft PowerNBT plugin
https://www.spigotmc.org/resources/powernbt.9098/
MIT License
39 stars 25 forks source link

Writing on blocks #20

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hello, I'm trying to use the PowerNBT api. It is loaded as a plugin and added in maven as a dependency (which is correctly resolved). Maybe i'm misusing it ? Is NBTManager#write(Block, NBTCompound) not properly working ?

NBTManager manager = plugin.getNBTManager(); NBTCompound compound = manager.read(container); compound.put("placedBy", uniqueId.toString()); manager.write(container, compound); Bukkit.broadcastMessage("1: " + compound.getString("placedBy")); Bukkit.broadcastMessage("2: " + manager.read(container).getString("placedBy"));

Output : 1: 2: nothing

DPOH-VAR commented 7 years ago

NBTManager#write(Block, NBTCompound) method works only if block is TileEntity (it not works for usual blocks: stone, air, wood etc) you can write to the block only certain values, see wiki: http://minecraft.gamepedia.com/Chunk_format#Block_entity_format

"placedBy" is not described in wiki so you can not write it to the block. Also you can not change "x", "y" "z" tags of tile entities (this is the plugin restriction).