From d0a3620c2dc8a22438808f395348c100a183a618 Mon Sep 17 00:00:00 2001 From: Parker Hawke Date: Tue, 1 May 2018 15:27:59 -0400 Subject: [PATCH] Implement Arrow tile methods --- nms-patches/EntityArrow.patch | 13 +++++++++++++ .../bukkit/craftbukkit/entity/CraftArrow.java | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/nms-patches/EntityArrow.patch b/nms-patches/EntityArrow.patch index 8da69dc294..3d27615c30 100644 --- a/nms-patches/EntityArrow.patch +++ b/nms-patches/EntityArrow.patch @@ -14,6 +14,19 @@ public abstract class EntityArrow extends Entity implements IProjectile { private static final Predicate f = Predicates.and(new Predicate[] { IEntitySelector.e, IEntitySelector.a, new Predicate() { +@@ -17,9 +24,9 @@ + } + }}); + private static final DataWatcherObject g = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a); +- private int h; +- private int at; +- private int au; ++ public int h; // PAIL: private->public ++ public int at; // PAIL: private->public ++ public int au; // PAIL: private->public + private Block av; + private int aw; + public boolean inGround; @@ -50,6 +57,7 @@ public EntityArrow(World world, EntityLiving entityliving) { this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index 3974778d98..9942576716 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import net.minecraft.server.EntityArrow; import org.apache.commons.lang.Validate; +import org.bukkit.block.Block; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Arrow; import org.bukkit.entity.EntityType; @@ -46,6 +47,21 @@ public class CraftArrow extends AbstractProjectile implements Arrow { getHandle().projectileSource = shooter; } + @Override + public boolean isInBlock() { + return getHandle().inGround; + } + + @Override + public Block getAttachedBlock() { + if (!isInBlock()) { + return null; + } + + EntityArrow handle = getHandle(); + return getWorld().getBlockAt(handle.h, handle.at, handle.au); // PAIL: rename tileX, tileY, tileZ + } + @Override public PickupStatus getPickupStatus() { return PickupStatus.values()[getHandle().fromPlayer.ordinal()];