SPIGOT-2980: Improve SpawnEgg NBT application and ItemStack conversion.

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2017-01-02 16:13:25 +11:00
parent 86649dea13
commit a1cc3a4382
3 changed files with 36 additions and 10 deletions

View File

@@ -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;
}

View File

@@ -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