aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/network/FriendlyByteBuf.java.patch
blob: ce4b89510cd7f5ee0dde2037d3eea05979125f06 (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
--- a/net/minecraft/network/FriendlyByteBuf.java
+++ b/net/minecraft/network/FriendlyByteBuf.java
@@ -81,6 +81,8 @@
 import org.joml.Quaternionf;
 import org.joml.Vector3f;
 
+import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
+
 public class FriendlyByteBuf extends ByteBuf {
 
     public static final int DEFAULT_NBT_QUOTA = 2097152;
@@ -584,7 +586,7 @@
         try {
             NbtIo.writeAnyTag((Tag) tag, new ByteBufOutputStream(this));
             return this;
-        } catch (IOException ioexception) {
+        } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
             throw new EncoderException(ioexception);
         }
     }
@@ -611,8 +613,8 @@
         }
     }
 
-    public FriendlyByteBuf writeItem(ItemStack itemstack) {
-        if (itemstack.isEmpty()) {
+    public FriendlyByteBuf writeItem(ItemStack stack) {
+        if (stack.isEmpty() || stack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
             this.writeBoolean(false);
         } else {
             this.writeBoolean(true);
@@ -641,6 +643,11 @@
             ItemStack itemstack = new ItemStack(item, b0);
 
             itemstack.setTag(this.readNbt());
+            // CraftBukkit start
+            if (itemstack.getTag() != null) {
+                CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
+            }
+            // CraftBukkit end
             return itemstack;
         }
     }