PaperMC/Spigot-Server-Patches/0204-Fix-NFE-when-attempting-to-read-EMPTY-ItemStack.patch

24 lines
1.1 KiB
Diff
Raw Normal View History

2018-01-11 06:31:19 +01:00
From a7d08f6d229771a964acc992fe496836026f5ec8 Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Sun, 9 Apr 2017 23:50:15 -0700
2017-04-11 05:11:26 +02:00
Subject: [PATCH] Fix NFE when attempting to read EMPTY ItemStack
2017-04-11 05:11:26 +02:00
Thanks @gabizou
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
2018-01-11 06:31:19 +01:00
index 9465f4c1..52cb34ab 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -119,7 +119,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"));
--
2018-01-11 06:31:19 +01:00
2.14.3