Additional ExplosiveMinecart API (#8896)

This commit is contained in:
SoSeDiK
2023-02-26 18:01:43 +02:00
parent 6a50027d5d
commit 903747cc3a
2 changed files with 52 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ Subject: [PATCH] Missing Entity Behavior API
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev> Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com> Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com>
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@@ -1185,19 +1186,44 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public interface ExplosiveMinecart extends Minecart { public interface ExplosiveMinecart extends Minecart {
+ // Paper start - Entity API + // 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 + * @param fuseTicks fuse ticks or -1 if the fuse isn't primed
+ */ + */
+ void setFuseTicks(int fuseTicks); + 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 + * @return number of ticks or -1 if the fuse isn't primed
+ */ + */
+ int getFuseTicks(); + 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 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View File

@@ -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 attackTick
public net.minecraft.world.entity.monster.Ravager stunnedTick public net.minecraft.world.entity.monster.Ravager stunnedTick
public net.minecraft.world.entity.monster.Ravager roarTick 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.vehicle.MinecartTNT fuse
public net.minecraft.world.entity.monster.Endermite life public net.minecraft.world.entity.monster.Endermite life
public net.minecraft.world.entity.vehicle.MinecartHopper cooldownTime 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 <nassim@njahnke.dev> Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com> Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com>
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@@ -818,6 +820,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public int getFuseTicks() { + public int getFuseTicks() {
+ return this.getHandle().getFuse(); + 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 + // Paper end
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java