diff --git a/src/main/java/net/minestom/server/data/NbtDataImpl.java b/src/main/java/net/minestom/server/data/NbtDataImpl.java index fb479fda8..5e84b5eba 100644 --- a/src/main/java/net/minestom/server/data/NbtDataImpl.java +++ b/src/main/java/net/minestom/server/data/NbtDataImpl.java @@ -45,7 +45,8 @@ public class NbtDataImpl extends DataImpl { Check.notNull(nbt, "The type '" + type + "' is not supported within NbtDataImpl, if you wish to use a custom type you can encode the value into a byte array using a DataType"); - nbtCompound.set(KEY_PREFIX + key, nbt); + final String finalKey = KEY_PREFIX + key; + nbtCompound.set(finalKey, nbt); } } diff --git a/src/main/java/net/minestom/server/utils/NBTUtils.java b/src/main/java/net/minestom/server/utils/NBTUtils.java index 58facffe0..bdd736808 100644 --- a/src/main/java/net/minestom/server/utils/NBTUtils.java +++ b/src/main/java/net/minestom/server/utils/NBTUtils.java @@ -188,21 +188,21 @@ public final class NBTUtils { // Meta specific field final ItemMeta itemMeta = item.getItemMeta(); - if (itemMeta == null) - return; - itemMeta.read(nbt); + if (itemMeta != null) { + itemMeta.read(nbt); + } NbtDataImpl customData = null; for (String key : nbt.getKeys()) { if (key.startsWith(NbtDataImpl.KEY_PREFIX)) { if (customData == null) { customData = new NbtDataImpl(); + item.setData(customData); } final NBT keyNbt = nbt.get(key); final String dataKey = key.replaceFirst(NbtDataImpl.KEY_PREFIX, ""); final Object dataValue = fromNBT(keyNbt); - customData.set(dataKey, dataValue); } }