From f6925351336799e7920d1a1cc75a69cb61a7ee20 Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Mon, 27 Aug 2018 02:01:09 -0500 Subject: [PATCH] Add More Creeper API (#1372) --- Spigot-API-Patches/Add-More-Creeper-API.patch | 100 ++++++++++++++++ .../Add-PhantomPreSpawnEvent.patch | 4 +- .../Add-More-Creeper-API.patch | 111 ++++++++++++++++++ 3 files changed, 213 insertions(+), 2 deletions(-) create mode 100644 Spigot-API-Patches/Add-More-Creeper-API.patch create mode 100644 Spigot-Server-Patches/Add-More-Creeper-API.patch diff --git a/Spigot-API-Patches/Add-More-Creeper-API.patch b/Spigot-API-Patches/Add-More-Creeper-API.patch new file mode 100644 index 0000000000..3e56f5241b --- /dev/null +++ b/Spigot-API-Patches/Add-More-Creeper-API.patch @@ -0,0 +1,100 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Fri, 24 Aug 2018 11:50:16 -0500 +Subject: [PATCH] Add More Creeper API + + +diff --git a/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java +new file mode 100644 +index 00000000..3d10bb03 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.event.entity; ++ ++import org.bukkit.entity.Creeper; ++import org.bukkit.event.Cancellable; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.entity.EntityEvent; ++ ++/** ++ * Called when a Creeper is ignite flag is changed (armed/disarmed to explode). ++ */ ++public class CreeperIgniteEvent extends EntityEvent implements Cancellable { ++ private static final HandlerList handlers = new HandlerList(); ++ private boolean canceled; ++ private boolean ignited; ++ ++ public CreeperIgniteEvent(Creeper creeper, boolean ignited) { ++ super(creeper); ++ this.ignited = ignited; ++ } ++ ++ @Override ++ public Creeper getEntity() { ++ return (Creeper) entity; ++ } ++ ++ public boolean isIgnited() { ++ return ignited; ++ } ++ ++ public void setIgnited(boolean ignited) { ++ this.ignited = ignited; ++ } ++ ++ public boolean isCancelled() { ++ return canceled; ++ } ++ ++ public void setCancelled(boolean cancel) { ++ canceled = cancel; ++ } ++ ++ @Override ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +diff --git a/src/main/java/org/bukkit/entity/Creeper.java b/src/main/java/org/bukkit/entity/Creeper.java +index f957d836..b9877fb8 100644 +--- a/src/main/java/org/bukkit/entity/Creeper.java ++++ b/src/main/java/org/bukkit/entity/Creeper.java +@@ -0,0 +0,0 @@ public interface Creeper extends Monster { + * @return the explosion radius + */ + public int getExplosionRadius(); ++ ++ // Paper start ++ /** ++ * Set whether creeper is ignited or not (armed to explode) ++ * ++ * @param ignited New ignited state ++ */ ++ public void setIgnited(boolean ignited); ++ ++ /** ++ * Check if creeper is ignited or not (armed to explode) ++ * ++ * @return Ignited state ++ */ ++ public boolean isIgnited(); ++ ++ /** ++ * Get the number of ticks this creeper has been ignited (armed to explode) ++ * ++ * @return Ticks creeper has been ignited ++ */ ++ public int getFuseTicks(); ++ ++ /** ++ * Make the creeper explode (no waiting for fuse) ++ */ ++ public void explode(); ++ // Paper end + } +-- \ No newline at end of file diff --git a/Spigot-API-Patches/Add-PhantomPreSpawnEvent.patch b/Spigot-API-Patches/Add-PhantomPreSpawnEvent.patch index 60c899c4d3..bd6ab963de 100644 --- a/Spigot-API-Patches/Add-PhantomPreSpawnEvent.patch +++ b/Spigot-API-Patches/Add-PhantomPreSpawnEvent.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Add PhantomPreSpawnEvent diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java new file mode 100644 -index 00000000..303a1ec9 +index 000000000..303a1ec9b --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java @@ -0,0 +0,0 @@ @@ -41,7 +41,7 @@ index 00000000..303a1ec9 + } +} diff --git a/src/main/java/org/bukkit/entity/Phantom.java b/src/main/java/org/bukkit/entity/Phantom.java -index 1a1044ed..65b703a2 100644 +index 1a1044edc..65b703a2d 100644 --- a/src/main/java/org/bukkit/entity/Phantom.java +++ b/src/main/java/org/bukkit/entity/Phantom.java @@ -0,0 +0,0 @@ public interface Phantom extends Flying { diff --git a/Spigot-Server-Patches/Add-More-Creeper-API.patch b/Spigot-Server-Patches/Add-More-Creeper-API.patch new file mode 100644 index 0000000000..bacbc4f754 --- /dev/null +++ b/Spigot-Server-Patches/Add-More-Creeper-API.patch @@ -0,0 +1,111 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Fri, 24 Aug 2018 11:50:26 -0500 +Subject: [PATCH] Add More Creeper API + + +diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java +index 19022b6e24..1729297766 100644 +--- a/src/main/java/net/minecraft/server/EntityCreeper.java ++++ b/src/main/java/net/minecraft/server/EntityCreeper.java +@@ -0,0 +0,0 @@ public class EntityCreeper extends EntityMonster { + private static final DataWatcherObject b = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.i); + private static final DataWatcherObject c = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.i);private static final DataWatcherObject isIgnitedDW = c; // Paper OBFHELPER + private int bC; +- private int fuseTicks; ++ public int fuseTicks; // Paper - public + public int maxFuseTicks = 30; + public int explosionRadius = 3; + private int bG; +@@ -0,0 +0,0 @@ public class EntityCreeper extends EntityMonster { + public void tick() { + if (this.isAlive()) { + this.bC = this.fuseTicks; +- if (this.isIgnited()) { +- this.a(1); +- } ++ // Paper start - This is no longer needed as the state is being set in setIgnited() now. ++ // Ensures the CreeperIgniteEvent is not spammed every tick ++ //if (this.isIgnited()) { ++ // this.a(1); ++ //} ++ // Paper end + + int i = this.dz(); + +@@ -0,0 +0,0 @@ public class EntityCreeper extends EntityMonster { + return LootTables.x; + } + ++ public int getState() { return dz(); } // Paper - OBFHELPER + public int dz() { + return ((Integer) this.datawatcher.get(EntityCreeper.a)).intValue(); + } + ++ public void setState(int state) { a(state); } // Paper - OBFHELPER + public void a(int i) { +- this.datawatcher.set(EntityCreeper.a, Integer.valueOf(i)); ++ // Paper start ++ if (getState() != i) { ++ com.destroystokyo.paper.event.entity.CreeperIgniteEvent event = new com.destroystokyo.paper.event.entity.CreeperIgniteEvent((org.bukkit.entity.Creeper) getBukkitEntity(), i == 1); ++ if (event.callEvent()) { ++ this.datawatcher.set(EntityCreeper.a, event.isIgnited() ? 1 : -1); ++ } ++ } ++ // Paper end + } + + public void onLightningStrike(EntityLightning entitylightning) { +@@ -0,0 +0,0 @@ public class EntityCreeper extends EntityMonster { + return super.a(entityhuman, enumhand); + } + ++ public void explode() { this.dE(); } // Paper - OBFHELPER + private void dE() { + if (!this.world.isClientSide) { + boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); +@@ -0,0 +0,0 @@ public class EntityCreeper extends EntityMonster { + return ((Boolean) this.datawatcher.get(EntityCreeper.c)).booleanValue(); + } + ++ // Paper start ++ public void setIgnited(boolean ignited) { ++ this.datawatcher.set(EntityCreeper.c, ignited); ++ setState(ignited ? 1 : -1); ++ } ++ + public void dB() { +- this.datawatcher.set(EntityCreeper.c, Boolean.valueOf(true)); ++ setIgnited(true); ++ // Paper end + } + + public boolean canCauseHeadDrop() { +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java +index ffebb54caa..ab2b20a0d4 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java +@@ -0,0 +0,0 @@ public class CraftCreeper extends CraftMonster implements Creeper { + public EntityType getType() { + return EntityType.CREEPER; + } ++ ++ // Paper start ++ public void setIgnited(boolean ignited) { ++ getHandle().setIgnited(ignited); ++ } ++ ++ public boolean isIgnited() { ++ return getHandle().isIgnited(); ++ } ++ ++ public int getFuseTicks() { ++ return getHandle().fuseTicks; ++ } ++ ++ public void explode() { ++ getHandle().explode(); ++ } ++ // Paper end + } +-- \ No newline at end of file