aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0211-Fix-NFE-when-attempting-to-read-EMPTY-ItemStack.patch
blob: 1e1f8857432bc0165896d2c41f345d636cf029d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
From 409d9321d3f2a0e641c01c82db43c5c0c719f3dc Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Sun, 9 Apr 2017 23:50:15 -0700
Subject: [PATCH] Fix NFE when attempting to read EMPTY ItemStack

Thanks @gabizou

diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index 548da18e0..29902769f 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -97,7 +97,7 @@ public final class ItemStack {
 
     // CraftBukkit - break into own method
     public void load(NBTTagCompound nbttagcompound) {
-        this.item = Item.b(nbttagcompound.getString("id"));
+        this.item = nbttagcompound.hasKeyOfType("id", 8) ? Item.b(nbttagcompound.getString("id")) : Item.getItemOf(Blocks.AIR); // Paper - fix NumberFormatException caused by attempting to read an EMPTY ItemStack
         this.count = nbttagcompound.getByte("Count");
         // CraftBukkit start - Route through setData for filtering
         // this.damage = Math.max(0, nbttagcompound.getShort("Damage"));
-- 
2.12.2.windows.2