craftbukkit/nms-patches/net/minecraft/network/PacketDataSerializer.patch

51 lines
1.8 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/network/PacketDataSerializer.java
+++ b/net/minecraft/network/PacketDataSerializer.java
@@ -39,6 +39,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 final ByteBuf a;
2021-03-16 09:00:00 +11:00
@@ -167,7 +169,7 @@
2015-02-26 22:41:06 +00:00
}
public <T extends Enum<T>> T a(Class<T> oclass) {
2019-04-23 12:00:00 +10:00
- return ((Enum[]) oclass.getEnumConstants())[this.i()];
+ return ((T[]) oclass.getEnumConstants())[this.i()]; // CraftBukkit - fix decompile error
2015-02-26 22:41:06 +00:00
}
2016-03-01 08:32:46 +11:00
public PacketDataSerializer a(Enum<?> oenum) {
2021-03-16 09:00:00 +11:00
@@ -244,7 +246,7 @@
} else {
try {
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
- } catch (IOException ioexception) {
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
throw new EncoderException(ioexception);
}
}
2021-03-16 09:00:00 +11:00
@@ -281,7 +283,7 @@
}
2016-11-17 12:41:03 +11:00
public PacketDataSerializer a(ItemStack itemstack) {
- if (itemstack.isEmpty()) {
+ if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
2018-10-23 06:00:00 +11:00
this.writeBoolean(false);
} else {
2018-10-23 06:00:00 +11:00
this.writeBoolean(true);
2021-03-16 09:00:00 +11:00
@@ -310,6 +312,11 @@
2018-10-23 06:00:00 +11:00
ItemStack itemstack = new ItemStack(Item.getById(i), b0);
2019-04-23 12:00:00 +10:00
itemstack.setTag(this.l());
+ // CraftBukkit start
+ if (itemstack.getTag() != null) {
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
+ }
+ // CraftBukkit end
2016-11-17 12:41:03 +11:00
return itemstack;
}
2016-11-17 12:41:03 +11:00
}