mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-12 15:08:27 +02:00
SPIGOT-2842: Improve item age handling
This commit is contained in:
parent
c3d951ddcd
commit
78c7614349
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user