mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 22:13:42 +01:00
SPIGOT-4576: Fix attributes in itemstack internal data being lost
This commit is contained in:
parent
8059a937eb
commit
50fbc3f190
@ -111,6 +111,8 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void deserializeInternal(NBTTagCompound tag, Object context) {
|
void deserializeInternal(NBTTagCompound tag, Object context) {
|
||||||
|
super.deserializeInternal(tag, context);
|
||||||
|
|
||||||
if (tag.hasKeyOfType(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
if (tag.hasKeyOfType(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
||||||
blockEntityTag = tag.getCompound(BLOCK_ENTITY_TAG.NBT);
|
blockEntityTag = tag.getCompound(BLOCK_ENTITY_TAG.NBT);
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
|||||||
|
|
||||||
static Multimap<Attribute, AttributeModifier> buildModifiers(NBTTagCompound tag, ItemMetaKey key) {
|
static Multimap<Attribute, AttributeModifier> buildModifiers(NBTTagCompound tag, ItemMetaKey key) {
|
||||||
Multimap<Attribute, AttributeModifier> modifiers = HashMultimap.create();
|
Multimap<Attribute, AttributeModifier> modifiers = HashMultimap.create();
|
||||||
if (!tag.hasKey(key.NBT)) {
|
if (!tag.hasKeyOfType(key.NBT, CraftMagicNumbers.NBT.TAG_LIST)) {
|
||||||
return modifiers;
|
return modifiers;
|
||||||
}
|
}
|
||||||
NBTTagList mods = tag.getList(key.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);
|
NBTTagList mods = tag.getList(key.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);
|
||||||
@ -504,6 +504,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void deserializeInternal(NBTTagCompound tag, Object context) {
|
void deserializeInternal(NBTTagCompound tag, Object context) {
|
||||||
|
// SPIGOT-4576: Need to migrate from internal to proper data
|
||||||
|
if (tag.hasKeyOfType(ATTRIBUTES.NBT, CraftMagicNumbers.NBT.TAG_LIST)) {
|
||||||
|
this.attributeModifiers = buildModifiers(tag, ATTRIBUTES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Map<Enchantment, Integer> buildEnchantments(Map<String, Object> map, ItemMetaKey key) {
|
static Map<Enchantment, Integer> buildEnchantments(Map<String, Object> map, ItemMetaKey key) {
|
||||||
|
@ -58,6 +58,8 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void deserializeInternal(NBTTagCompound tag, Object context) {
|
void deserializeInternal(NBTTagCompound tag, Object context) {
|
||||||
|
super.deserializeInternal(tag, context);
|
||||||
|
|
||||||
if (tag.hasKeyOfType(SKULL_PROFILE.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
if (tag.hasKeyOfType(SKULL_PROFILE.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
||||||
profile = GameProfileSerializer.deserialize(tag.getCompound(SKULL_PROFILE.NBT));
|
profile = GameProfileSerializer.deserialize(tag.getCompound(SKULL_PROFILE.NBT));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user