--- a/net/minecraft/network/PacketDataSerializer.java +++ b/net/minecraft/network/PacketDataSerializer.java @@ -55,6 +55,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; @@ -123,7 +125,7 @@ public > C a(IntFunction intfunction, Function function) { int i = this.j(); - 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)); @@ -134,7 +136,7 @@ public void a(Collection collection, BiConsumer biconsumer) { this.d(collection.size()); - Iterator iterator = collection.iterator(); + Iterator iterator = collection.iterator(); // CraftBukkit - decompile error while (iterator.hasNext()) { T t0 = iterator.next(); @@ -145,7 +147,7 @@ } public List a(Function function) { - return (List) this.a(Lists::newArrayListWithCapacity, function); + return (List) this.a((java.util.function.IntFunction) Lists::newArrayListWithCapacity, function); // CraftBukkit - decompile error } public IntList a() { @@ -161,12 +163,12 @@ public void a(IntList intlist) { this.d(intlist.size()); - intlist.forEach(this::d); + intlist.forEach((java.util.function.IntConsumer) this::d); // CraftBukkit - decompile error } public > M a(IntFunction intfunction, Function function, Function function1) { int i = this.j(); - 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); @@ -355,7 +357,7 @@ } public > T a(Class oclass) { - return ((Enum[]) oclass.getEnumConstants())[this.j()]; + return ((T[]) oclass.getEnumConstants())[this.j()]; // CraftBukkit - fix decompile error } public PacketDataSerializer a(Enum oenum) { @@ -432,7 +434,7 @@ } else { try { NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); - } catch (IOException ioexception) { + } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception throw new EncoderException(ioexception); } } @@ -469,7 +471,7 @@ } public PacketDataSerializer a(ItemStack itemstack) { - if (itemstack.isEmpty()) { + if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() this.writeBoolean(false); } else { this.writeBoolean(true); @@ -498,6 +500,11 @@ ItemStack itemstack = new ItemStack(Item.getById(i), b0); itemstack.setTag(this.m()); + // CraftBukkit start + if (itemstack.getTag() != null) { + CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); + } + // CraftBukkit end return itemstack; } }