From b54b9409e02391f927767457bdaa6b685819f3e8 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 27 Dec 2018 12:02:17 +1100 Subject: [PATCH] SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock --- nms-patches/EntityArrow.patch | 9 +++++++++ nms-patches/EntityItem.patch | 8 ++++++-- .../java/org/bukkit/craftbukkit/entity/CraftArrow.java | 8 ++++++++ .../java/org/bukkit/craftbukkit/entity/CraftItem.java | 8 ++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/nms-patches/EntityArrow.patch b/nms-patches/EntityArrow.patch index ef27ceafb1..91940b745d 100644 --- a/nms-patches/EntityArrow.patch +++ b/nms-patches/EntityArrow.patch @@ -14,6 +14,15 @@ public abstract class EntityArrow extends Entity implements IProjectile { private static final Predicate g = IEntitySelector.f.and(IEntitySelector.a.and(Entity::isInteractable)); +@@ -22,7 +29,7 @@ + public EntityArrow.PickupStatus fromPlayer; + public int shake; + public UUID shooter; +- private int despawnCounter; ++ public int despawnCounter; // PAIL + private int aB; + private double damage; + public int knockbackStrength; @@ -250,6 +257,7 @@ } diff --git a/nms-patches/EntityItem.patch b/nms-patches/EntityItem.patch index f12c053cdc..de24d3261c 100644 --- a/nms-patches/EntityItem.patch +++ b/nms-patches/EntityItem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityItem.java +++ b/net/minecraft/server/EntityItem.java -@@ -3,6 +3,10 @@ +@@ -3,16 +3,21 @@ import java.util.Iterator; import java.util.UUID; import javax.annotation.Nullable; @@ -11,7 +11,11 @@ public class EntityItem extends Entity { -@@ -13,6 +17,7 @@ + private static final DataWatcherObject b = DataWatcher.a(EntityItem.class, DataWatcherRegistry.g); +- private int age; ++ public int age; // PAIL + public int pickupDelay; + private int e; private UUID f; private UUID g; public float a; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index 8aa1eebbfb..75dad21cd4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -84,6 +84,14 @@ public class CraftArrow extends AbstractProjectile implements Arrow { getHandle().fromPlayer = EntityArrow.PickupStatus.a(status.ordinal()); } + @Override + public void setTicksLived(int value) { + super.setTicksLived(value); + + // Second field for EntityArrow + getHandle().despawnCounter = value; + } + @Override public EntityArrow getHandle() { return (EntityArrow) entity; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java index a17a537d69..55d6bacf77 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java @@ -37,6 +37,14 @@ public class CraftItem extends CraftEntity implements Item { item.pickupDelay = Math.min(delay, Short.MAX_VALUE); } + @Override + public void setTicksLived(int value) { + super.setTicksLived(value); + + // Second field for EntityItem + item.age = value; + } + @Override public String toString() { return "CraftItem";