Paper/Spigot-Server-Patches/0212-Fix-NFE-when-attempting-to-read-EMPTY-ItemStack.patch
Shane Freeder ffb572ce9a
Remove Ignore invalid Marker Icon ID's in maps
Spigot has patched this issue inside MapIcon, meaning that we no longer need to maintain this patch; Spigots patch also fixes #668 in that it will verify the length of the array, as well as protect against a negative type value being fetched from the array. Only real change is that Spigots patch returns a MapIcon.Type.PLAYER, instead of the RED_MARKER as originally PR'd by Aikar.
2017-04-22 15:52:56 +01:00

24 lines
1.1 KiB
Diff

From 2f6bff5870596a421be90ada961ce01b515e9089 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 45ebd3f6..cf204f41 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