From 1c40a81828adf0214b19ba7cb0de935dd4e09d54 Mon Sep 17 00:00:00 2001 From: Senmori Date: Sat, 3 Feb 2018 17:48:41 +1100 Subject: Expand EnderSignal API --- nms-patches/EntityEnderSignal.patch | 19 +++++++++++ .../craftbukkit/entity/CraftEnderSignal.java | 37 +++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 nms-patches/EntityEnderSignal.patch diff --git a/nms-patches/EntityEnderSignal.patch b/nms-patches/EntityEnderSignal.patch new file mode 100644 index 00000000..b611b974 --- /dev/null +++ b/nms-patches/EntityEnderSignal.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/server/EntityEnderSignal.java ++++ b/net/minecraft/server/EntityEnderSignal.java +@@ -2,11 +2,11 @@ + + public class EntityEnderSignal extends Entity { + +- private double a; +- private double b; +- private double c; +- private int d; +- private boolean e; ++ public double a; // CraftBukkit private -> public // PAIL rename targetX ++ public double b; // CraftBukkit private -> public // PAIL rename targetY ++ public double c; // CraftBukkit private -> public // PAIL rename targetZ ++ public int d; // CraftBukkit private -> public // PAIL rename despawnTimer ++ public boolean e; // CraftBukkit private -> public // PAIL rename shouldDropItem + + public EntityEnderSignal(World world) { + super(world); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java index e3a5081e..aaa624ae 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -1,6 +1,9 @@ package org.bukkit.craftbukkit.entity; +import com.google.common.base.Preconditions; +import net.minecraft.server.BlockPosition; import net.minecraft.server.EntityEnderSignal; +import org.bukkit.Location; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EnderSignal; import org.bukkit.entity.EntityType; @@ -20,7 +23,39 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { return "CraftEnderSignal"; } + @Override public EntityType getType() { return EntityType.ENDER_SIGNAL; } -} \ No newline at end of file + + @Override + public Location getTargetLocation() { + return new Location(getWorld(), getHandle().a, getHandle().b, getHandle().c, getHandle().yaw, getHandle().pitch); // PAIL rename targetX, targetY, targetZ + } + + @Override + public void setTargetLocation(Location location) { + Preconditions.checkArgument(getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds"); + getHandle().a(new BlockPosition(location.getX(), location.getY(), location.getZ())); + } + + @Override + public boolean getDropItem() { + return getHandle().e; // PAIL rename getDropItem + } + + @Override + public void setDropItem(boolean shouldDropItem) { + getHandle().e = shouldDropItem; // PAIL rename getDropItem + } + + @Override + public int getDespawnTimer() { + return getHandle().d; // PAIL rename despawnTimer + } + + @Override + public void setDespawnTimer(int time) { + getHandle().d = time; // PAIL rename despawnTimer + } +} -- cgit v1.2.3