mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-29 04:28:21 +01:00
Fixed NbtDataImpl not working in creative mode
This commit is contained in:
parent
78bf5dda05
commit
99d27b78c4
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user