mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 22:44:17 +01:00
51 lines
1.7 KiB
Diff
51 lines
1.7 KiB
Diff
--- a/net/minecraft/server/PacketDataSerializer.java
|
|
+++ b/net/minecraft/server/PacketDataSerializer.java
|
|
@@ -20,6 +20,8 @@
|
|
import java.nio.charset.Charset;
|
|
import java.util.UUID;
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
|
|
+
|
|
public class PacketDataSerializer extends ByteBuf {
|
|
|
|
private final ByteBuf a;
|
|
@@ -99,7 +101,7 @@
|
|
}
|
|
|
|
public <T extends Enum<T>> T a(Class<T> oclass) {
|
|
- return ((Enum[]) oclass.getEnumConstants())[this.g()];
|
|
+ return ((T[]) oclass.getEnumConstants())[this.g()]; // CraftBukkit - fix decompile error
|
|
}
|
|
|
|
public PacketDataSerializer a(Enum<?> oenum) {
|
|
@@ -176,7 +178,7 @@
|
|
} else {
|
|
try {
|
|
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
|
|
- } catch (IOException ioexception) {
|
|
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
|
|
throw new EncoderException(ioexception);
|
|
}
|
|
}
|
|
@@ -202,7 +204,7 @@
|
|
}
|
|
|
|
public PacketDataSerializer a(ItemStack itemstack) {
|
|
- if (itemstack == null) {
|
|
+ if (itemstack == null || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
|
|
this.writeShort(-1);
|
|
} else {
|
|
this.writeShort(Item.getId(itemstack.getItem()));
|
|
@@ -230,6 +232,11 @@
|
|
|
|
itemstack = new ItemStack(Item.getById(short0), b0, short1);
|
|
itemstack.setTag(this.j());
|
|
+ // CraftBukkit start
|
|
+ if (itemstack.getTag() != null) {
|
|
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
return itemstack;
|