From 903747cc3a7217032fa01712fe6a89f2fd698a8f Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Sun, 26 Feb 2023 18:01:43 +0200 Subject: [PATCH] Additional ExplosiveMinecart API (#8896) --- patches/api/Missing-Entity-Behavior-API.patch | 32 +++++++++++++++++-- .../server/Missing-Entity-Behavior-API.patch | 23 +++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/patches/api/Missing-Entity-Behavior-API.patch b/patches/api/Missing-Entity-Behavior-API.patch index 086f1f07ed..42a9998fa3 100644 --- a/patches/api/Missing-Entity-Behavior-API.patch +++ b/patches/api/Missing-Entity-Behavior-API.patch @@ -6,6 +6,7 @@ Subject: [PATCH] Missing Entity Behavior API Co-authored-by: Nassim Jahnke Co-authored-by: Jake Potrebic Co-authored-by: William Blake Galbreath +Co-authored-by: SoSeDiK diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -1185,19 +1186,44 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public interface ExplosiveMinecart extends Minecart { + // Paper start - Entity API + /** -+ * Set the number of ticks until the minecart explodes after being primed. ++ * Set the number of ticks until the Minecart explodes after being primed. + * + * @param fuseTicks fuse ticks or -1 if the fuse isn't primed + */ + void setFuseTicks(int fuseTicks); + + /** -+ * Retrieve the number of ticks until the explosive minecart explodes ++ * Retrieve the number of ticks until the explosive Minecart explodes. + * + * @return number of ticks or -1 if the fuse isn't primed + */ + int getFuseTicks(); -+ // Paper end ++ ++ /** ++ * Checks whether this explosive Minecart is ignited (its fuse is primed). ++ * ++ * @return whether the Minecart is ignited ++ */ ++ boolean isIgnited(); ++ ++ /** ++ * Ignites this explosive Minecart, beginning its fuse. ++ */ ++ void ignite(); ++ ++ /** ++ * Immediately explodes the Minecart. ++ * Power will depend on the Minecart's horizontal speed. ++ */ ++ void explode(); ++ ++ /** ++ * Immediately explodes the Minecart with the specified power. ++ * ++ * @param power explosion power ++ */ ++ void explode(double power); ++ // Paper end - Entity API } diff --git a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java b/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/server/Missing-Entity-Behavior-API.patch b/patches/server/Missing-Entity-Behavior-API.patch index 2f53fc3692..bec126cb81 100644 --- a/patches/server/Missing-Entity-Behavior-API.patch +++ b/patches/server/Missing-Entity-Behavior-API.patch @@ -20,6 +20,7 @@ public net.minecraft.world.entity.ambient.Bat targetPosition public net.minecraft.world.entity.monster.Ravager attackTick public net.minecraft.world.entity.monster.Ravager stunnedTick public net.minecraft.world.entity.monster.Ravager roarTick +public net.minecraft.world.entity.vehicle.MinecartTNT explode(D)V public net.minecraft.world.entity.vehicle.MinecartTNT fuse public net.minecraft.world.entity.monster.Endermite life public net.minecraft.world.entity.vehicle.MinecartHopper cooldownTime @@ -33,6 +34,7 @@ public net.minecraft.world.entity.animal.Rabbit moreCarrotTicks Co-authored-by: Nassim Jahnke Co-authored-by: Jake Potrebic Co-authored-by: William Blake Galbreath +Co-authored-by: SoSeDiK diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -818,6 +820,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public int getFuseTicks() { + return this.getHandle().getFuse(); + } ++ ++ @Override ++ public boolean isIgnited() { ++ return this.getHandle().isPrimed(); ++ } ++ ++ @Override ++ public void ignite() { ++ this.getHandle().primeFuse(); ++ } ++ ++ @Override ++ public void explode() { ++ explode(this.getHandle().getDeltaMovement().horizontalDistanceSqr()); ++ } ++ ++ @Override ++ public void explode(double power) { ++ com.google.common.base.Preconditions.checkArgument(power >= 0 && Double.isFinite(power), "Explosion power must be a finite non-negative number"); ++ this.getHandle().explode(power); ++ } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java