mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-31 21:48:08 +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,
|
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");
|
"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
|
// Meta specific field
|
||||||
final ItemMeta itemMeta = item.getItemMeta();
|
final ItemMeta itemMeta = item.getItemMeta();
|
||||||
if (itemMeta == null)
|
if (itemMeta != null) {
|
||||||
return;
|
itemMeta.read(nbt);
|
||||||
itemMeta.read(nbt);
|
}
|
||||||
|
|
||||||
NbtDataImpl customData = null;
|
NbtDataImpl customData = null;
|
||||||
for (String key : nbt.getKeys()) {
|
for (String key : nbt.getKeys()) {
|
||||||
if (key.startsWith(NbtDataImpl.KEY_PREFIX)) {
|
if (key.startsWith(NbtDataImpl.KEY_PREFIX)) {
|
||||||
if (customData == null) {
|
if (customData == null) {
|
||||||
customData = new NbtDataImpl();
|
customData = new NbtDataImpl();
|
||||||
|
item.setData(customData);
|
||||||
}
|
}
|
||||||
final NBT keyNbt = nbt.get(key);
|
final NBT keyNbt = nbt.get(key);
|
||||||
|
|
||||||
final String dataKey = key.replaceFirst(NbtDataImpl.KEY_PREFIX, "");
|
final String dataKey = key.replaceFirst(NbtDataImpl.KEY_PREFIX, "");
|
||||||
final Object dataValue = fromNBT(keyNbt);
|
final Object dataValue = fromNBT(keyNbt);
|
||||||
|
|
||||||
customData.set(dataKey, dataValue);
|
customData.set(dataKey, dataValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user