summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft
diff options
context:
space:
mode:
authorNathan Adams <dinnerbone@dinnerbone.com>2012-01-20 16:40:27 +0000
committerNathan Adams <dinnerbone@dinnerbone.com>2012-01-20 16:40:27 +0000
commit85ab95cec7abc5cb39dbb94c169bd0ae3a9b2fef (patch)
treed872f953380a5e957156f23ab2033803e6862fa9 /src/main/java/net/minecraft
parent51a056ecd5820ff24a87f0c20a05024f68275224 (diff)
downloadcraftbukkit-85ab95cec7abc5cb39dbb94c169bd0ae3a9b2fef.tar
craftbukkit-85ab95cec7abc5cb39dbb94c169bd0ae3a9b2fef.tar.gz
craftbukkit-85ab95cec7abc5cb39dbb94c169bd0ae3a9b2fef.tar.lz
craftbukkit-85ab95cec7abc5cb39dbb94c169bd0ae3a9b2fef.tar.xz
craftbukkit-85ab95cec7abc5cb39dbb94c169bd0ae3a9b2fef.zip
Nullcheck EntityItem's ItemStack where required. This fixes BUKKIT-552
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r--src/main/java/net/minecraft/server/EntityItem.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index 332c4269..433616f4 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -21,7 +21,10 @@ public class EntityItem extends Entity {
this.height = this.length / 2.0F;
this.setPosition(d0, d1, d2);
this.itemStack = itemstack;
- // CraftBukkit start - infinite item fix
+ // CraftBukkit start - infinite item fix & nullcheck
+ if (this.itemStack == null) {
+ throw new IllegalArgumentException("Can't create an EntityItem for a null item");
+ }
if (this.itemStack.count <= -1) {
this.itemStack.count = 1;
}
@@ -117,7 +120,7 @@ public class EntityItem extends Entity {
public void b(NBTTagCompound nbttagcompound) {
nbttagcompound.setShort("Health", (short) ((byte) this.f));
nbttagcompound.setShort("Age", (short) this.age);
- nbttagcompound.setCompound("Item", this.itemStack.b(new NBTTagCompound()));
+ if (this.itemStack != null) nbttagcompound.setCompound("Item", this.itemStack.b(new NBTTagCompound())); // CraftBukkit - Nullchex!
}
public void a(NBTTagCompound nbttagcompound) {
@@ -132,7 +135,7 @@ public class EntityItem extends Entity {
}
public void a_(EntityHuman entityhuman) {
- if (!this.world.isStatic) {
+ if ((!this.world.isStatic) && (this.itemStack != null)) { // CraftBukkit - nullcheck
int i = this.itemStack.count;
// CraftBukkit start
@@ -180,6 +183,7 @@ public class EntityItem extends Entity {
}
public String getLocalizedName() {
+ if (this.itemStack == null) return LocaleI18n.a("item.unknown"); // CraftBukkit - nullcheck
return LocaleI18n.a("item." + this.itemStack.k());
}
}