--- a/net/minecraft/network/PacketDataSerializer.java +++ b/net/minecraft/network/PacketDataSerializer.java @@ -54,6 +54,8 @@ import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.Vec3D; +import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit + public class PacketDataSerializer extends ByteBuf { private static final int MAX_VARINT_SIZE = 5; @@ -122,7 +124,7 @@ public > C readCollection(IntFunction intfunction, Function function) { int i = this.readVarInt(); - C c0 = (Collection) intfunction.apply(i); + C c0 = intfunction.apply(i); // CraftBukkit - decompile error for (int j = 0; j < i; ++j) { c0.add(function.apply(this)); @@ -133,7 +135,7 @@ public void writeCollection(Collection collection, BiConsumer biconsumer) { this.writeVarInt(collection.size()); - Iterator iterator = collection.iterator(); + Iterator iterator = collection.iterator(); // CraftBukkit - decompile error while (iterator.hasNext()) { T t0 = iterator.next(); @@ -144,7 +146,7 @@ } public List readList(Function function) { - return (List) this.readCollection(Lists::newArrayListWithCapacity, function); + return (List) this.readCollection((java.util.function.IntFunction) Lists::newArrayListWithCapacity, function); // CraftBukkit - decompile error } public IntList readIntIdList() { @@ -160,12 +162,12 @@ public void writeIntIdList(IntList intlist) { this.writeVarInt(intlist.size()); - intlist.forEach(this::writeVarInt); + intlist.forEach((java.util.function.IntConsumer) this::writeVarInt); // CraftBukkit - decompile error } public > M readMap(IntFunction intfunction, Function function, Function function1) { int i = this.readVarInt(); - M m0 = (Map) intfunction.apply(i); + M m0 = intfunction.apply(i); // CraftBukkit - decompile error for (int j = 0; j < i; ++j) { K k0 = function.apply(this); @@ -354,7 +356,7 @@ } public > T readEnum(Class oclass) { - return ((Enum[]) oclass.getEnumConstants())[this.readVarInt()]; + return ((T[]) oclass.getEnumConstants())[this.readVarInt()]; // CraftBukkit - fix decompile error } public PacketDataSerializer writeEnum(Enum oenum) { @@ -431,7 +433,7 @@ } else { try { NBTCompressedStreamTools.write(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); - } catch (IOException ioexception) { + } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception throw new EncoderException(ioexception); } } @@ -468,7 +470,7 @@ } public PacketDataSerializer writeItem(ItemStack itemstack) { - if (itemstack.isEmpty()) { + if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() this.writeBoolean(false); } else { this.writeBoolean(true); @@ -497,6 +499,11 @@ ItemStack itemstack = new ItemStack(Item.byId(i), b0); itemstack.setTag(this.readNbt()); + // CraftBukkit start + if (itemstack.getTag() != null) { + CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); + } + // CraftBukkit end return itemstack; } }