From 78c7614349845f26cdb39514b7015e1c220dab37 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 25 Nov 2016 10:31:53 +1100 Subject: [PATCH] SPIGOT-2842: Improve item age handling --- nms-patches/EntityItem.patch | 39 +++++++----------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/nms-patches/EntityItem.patch b/nms-patches/EntityItem.patch index 3b425b41ba..4215e0198c 100644 --- a/nms-patches/EntityItem.patch +++ b/nms-patches/EntityItem.patch @@ -12,23 +12,11 @@ private String g; private String h; public float a; -+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit ++ private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit public EntityItem(World world, double d0, double d1, double d2) { super(world); -@@ -30,6 +32,11 @@ - - public EntityItem(World world, double d0, double d1, double d2, ItemStack itemstack) { - this(world, d0, d1, d2); -+ // CraftBukkit start - Can't set null items in the datawatcher -+ if (itemstack == null || itemstack.getItem() == null) { -+ return; -+ } -+ // CraftBukkit end - this.setItemStack(itemstack); - } - -@@ -54,9 +61,12 @@ +@@ -54,9 +56,12 @@ this.die(); } else { super.A_(); @@ -44,7 +32,7 @@ this.lastX = this.locX; this.lastY = this.locY; -@@ -104,9 +114,11 @@ +@@ -104,9 +109,11 @@ this.motY *= -0.5D; } @@ -56,7 +44,7 @@ this.ak(); if (!this.world.isClientSide) { -@@ -121,6 +133,12 @@ +@@ -121,6 +128,12 @@ } if (!this.world.isClientSide && this.age >= 6000) { @@ -69,7 +57,7 @@ this.die(); } -@@ -162,6 +180,7 @@ +@@ -162,6 +175,7 @@ } else if (itemstack1.getCount() + itemstack.getCount() > itemstack1.getMaxStackSize()) { return false; } else { @@ -77,7 +65,7 @@ itemstack1.add(itemstack.getCount()); entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay); entityitem.age = Math.min(entityitem.age, this.age); -@@ -208,6 +227,11 @@ +@@ -208,6 +222,11 @@ } else if (!this.getItemStack().isEmpty() && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) { return false; } else { @@ -89,20 +77,7 @@ this.ap(); this.f = (int) ((float) this.f - f); if (this.f <= 0) { -@@ -257,6 +281,12 @@ - - NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Item"); - -+ // CraftBukkit start - Handle missing "Item" compounds -+ if (nbttagcompound1 == null) { -+ this.die(); -+ return; -+ } -+ // CraftBukkit end - this.setItemStack(new ItemStack(nbttagcompound1)); - if (this.getItemStack().isEmpty()) { - this.die(); -@@ -270,6 +300,26 @@ +@@ -270,6 +289,26 @@ Item item = itemstack.getItem(); int i = itemstack.getCount();