From d38e9dcf0e2ea8a46912e6b4e00274a06c670b7c Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 30 Apr 2018 13:30:00 -0400 Subject: [PATCH] Enderman.teleportRandomly() Ability to trigger the vanilla "teleport randomly" mechanic of an enderman. --- .../0099-Enderman.teleportRandomly.patch | 32 +++++++++++++++++ .../0293-Enderman.teleportRandomly.patch | 34 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 Spigot-API-Patches/0099-Enderman.teleportRandomly.patch create mode 100644 Spigot-Server-Patches/0293-Enderman.teleportRandomly.patch diff --git a/Spigot-API-Patches/0099-Enderman.teleportRandomly.patch b/Spigot-API-Patches/0099-Enderman.teleportRandomly.patch new file mode 100644 index 000000000..e250867de --- /dev/null +++ b/Spigot-API-Patches/0099-Enderman.teleportRandomly.patch @@ -0,0 +1,32 @@ +From d530ef23afbee7ab48db7b45c2fb1942b7124d9f Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Mon, 30 Apr 2018 13:29:15 -0400 +Subject: [PATCH] Enderman.teleportRandomly() + +Ability to trigger the vanilla "teleport randomly" mechanic of an enderman. + +diff --git a/src/main/java/org/bukkit/entity/Enderman.java b/src/main/java/org/bukkit/entity/Enderman.java +index f537f697..52afa6f9 100644 +--- a/src/main/java/org/bukkit/entity/Enderman.java ++++ b/src/main/java/org/bukkit/entity/Enderman.java +@@ -7,6 +7,17 @@ import org.bukkit.material.MaterialData; + */ + public interface Enderman extends Monster { + ++ // Paper start ++ /** ++ * Try to teleport the enderman to a random nearby location. ++ * ++ * May conditionally fail if the random location was not valid ++ * @return If the enderman teleported successfully or not ++ */ ++ ++ public boolean teleportRandomly(); ++ // Paper end ++ + /** + * Get the id and data of the block that the Enderman is carrying. + * +-- +2.17.0 + diff --git a/Spigot-Server-Patches/0293-Enderman.teleportRandomly.patch b/Spigot-Server-Patches/0293-Enderman.teleportRandomly.patch new file mode 100644 index 000000000..3af61a057 --- /dev/null +++ b/Spigot-Server-Patches/0293-Enderman.teleportRandomly.patch @@ -0,0 +1,34 @@ +From 54a0c28176774e984ea077500e21a0b8a7c12e54 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Mon, 30 Apr 2018 13:29:44 -0400 +Subject: [PATCH] Enderman.teleportRandomly() + +Ability to trigger the vanilla "teleport randomly" mechanic of an enderman. + +diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java +index 7b1fb6b7b..3038a9e2b 100644 +--- a/src/main/java/net/minecraft/server/EntityEnderman.java ++++ b/src/main/java/net/minecraft/server/EntityEnderman.java +@@ -198,6 +198,7 @@ public class EntityEnderman extends EntityMonster { + super.M(); + } + ++ public boolean teleportRandomly() { return dm(); } // Paper - OBFHELPER + protected boolean dm() { + double d0 = this.locX + (this.random.nextDouble() - 0.5D) * 64.0D; + double d1 = this.locY + (double) (this.random.nextInt(64) - 32); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +index f602c2313..7e6af5d02 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +@@ -15,6 +15,7 @@ public class CraftEnderman extends CraftMonster implements Enderman { + super(server, entity); + } + ++ @Override public boolean teleportRandomly() { return getHandle().teleportRandomly(); } // Paper + public MaterialData getCarriedMaterial() { + IBlockData blockData = getHandle().getCarried(); + return (blockData == null) ? Material.AIR.getNewData((byte) 0) : CraftMagicNumbers.getMaterial(blockData.getBlock()).getNewData((byte) blockData.getBlock().toLegacyData(blockData)); +-- +2.17.0 +