SPIGOT-2980: Improve SpawnEgg NBT application and ItemStack conversion.
By: md_5 <git@md-5.net>
This commit is contained in:
@@ -40,9 +40,12 @@ public final class CraftItemStack extends ItemStack {
|
||||
return net.minecraft.server.ItemStack.a;
|
||||
}
|
||||
|
||||
net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount(), original.getDurability());
|
||||
net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount(), original.getDurability(), false);
|
||||
if (original.hasItemMeta()) {
|
||||
setItemMeta(stack, original.getItemMeta());
|
||||
} else {
|
||||
// Converted after setItemMeta
|
||||
stack.convertStack();
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta {
|
||||
void applyToItem(NBTTagCompound tag) {
|
||||
super.applyToItem(tag);
|
||||
|
||||
if (entityTag == null) {
|
||||
if (!isSpawnEggEmpty() && entityTag == null) {
|
||||
entityTag = new NBTTagCompound();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,9 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta {
|
||||
entityTag.setString(ENTITY_ID.NBT, new MinecraftKey(spawnedType.getName()).toString());
|
||||
}
|
||||
|
||||
tag.set(ENTITY_TAG.NBT, entityTag);
|
||||
if (entityTag != null) {
|
||||
tag.set(ENTITY_TAG.NBT, entityTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user