summaryrefslogtreecommitdiffstats
path: root/nms-patches/PacketDataSerializer.patch
blob: c0e3fd8badd84ed0ff1b54c822b24cf09efd312b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- /home/matt/mc-dev-private//net/minecraft/server/PacketDataSerializer.java	2015-02-26 22:40:22.899608136 +0000
+++ src/main/java/net/minecraft/server/PacketDataSerializer.java	2015-02-26 22:40:22.903608136 +0000
@@ -21,6 +21,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;
@@ -68,7 +70,7 @@
     }
 
     public <T extends Enum<T>> T a(Class<T> oclass) {
-        return ((Enum[]) oclass.getEnumConstants())[this.e()];
+        return ((T[]) oclass.getEnumConstants())[this.e()]; // CraftBukkit - fix decompile error
     }
 
     public void a(Enum<?> oenum) {
@@ -142,7 +144,7 @@
         } else {
             try {
                 NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
-            } catch (IOException ioexception) {
+            } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
                 throw new EncoderException(ioexception);
             }
         }
@@ -162,7 +164,7 @@
     }
 
     public void 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()));
@@ -189,6 +191,11 @@
 
             itemstack = new ItemStack(Item.getById(short0), b0, short1);
             itemstack.setTag(this.h());
+            // CraftBukkit start
+            if (itemstack.getTag() != null) {
+                CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
+            }
+            // CraftBukkit end
         }
 
         return itemstack;
@@ -803,16 +810,4 @@
     public boolean release(int i) {
         return this.a.release(i);
     }
-
-    public ReferenceCounted retain(int i) {
-        return this.retain(i);
-    }
-
-    public ReferenceCounted retain() {
-        return this.retain();
-    }
-
-    public int compareTo(Object object) {
-        return this.compareTo((ByteBuf) object);
-    }
 }