PaperMC/paper-server/nms-patches/net/minecraft/network/PacketDataSerializer.patch
CraftBukkit/Spigot b3a8254758 Update to Minecraft 1.17
By: md_5 <git@md-5.net>
2021-06-11 15:00:00 +10:00

92 lines
3.5 KiB
Diff

--- 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;
@@ -112,7 +114,7 @@
public <T, C extends Collection<T>> C a(IntFunction<C> intfunction, Function<PacketDataSerializer, T> 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));
@@ -123,7 +125,7 @@
public <T> void a(Collection<T> collection, BiConsumer<PacketDataSerializer, T> biconsumer) {
this.d(collection.size());
- Iterator iterator = collection.iterator();
+ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -134,7 +136,7 @@
}
public <T> List<T> a(Function<PacketDataSerializer, T> 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() {
@@ -150,12 +152,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 <K, V, M extends Map<K, V>> M a(IntFunction<M> intfunction, Function<PacketDataSerializer, K> function, Function<PacketDataSerializer, V> 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);
@@ -330,7 +332,7 @@
}
public <T extends Enum<T>> T a(Class<T> oclass) {
- return ((Enum[]) oclass.getEnumConstants())[this.j()];
+ return ((T[]) oclass.getEnumConstants())[this.j()]; // CraftBukkit - fix decompile error
}
public PacketDataSerializer a(Enum<?> oenum) {
@@ -407,7 +409,7 @@
} else {
try {
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
- } catch (IOException ioexception) {
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
throw new EncoderException(ioexception);
}
}
@@ -444,7 +446,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);
@@ -473,6 +475,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;
}
}