craftbukkit/nms-patches/EntityTNTPrimed.patch

55 lines
2 KiB
Diff
Raw Normal View History

2015-05-25 20:37:24 +10:00
--- a/net/minecraft/server/EntityTNTPrimed.java
+++ b/net/minecraft/server/EntityTNTPrimed.java
2020-10-25 18:10:08 +11:00
@@ -1,13 +1,16 @@
package net.minecraft.server;
2016-11-17 12:41:03 +11:00
import javax.annotation.Nullable;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
2016-11-17 12:41:03 +11:00
public class EntityTNTPrimed extends Entity {
2020-10-25 18:10:08 +11:00
private static final DataWatcherObject<Integer> FUSE_TICKS = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.b);
2016-11-17 12:41:03 +11:00
@Nullable
2020-10-25 18:10:08 +11:00
- private EntityLiving source;
+ public EntityLiving source; // PAIL private -> public
2019-04-23 12:00:00 +10:00
private int fuseTicks;
+ public float yield = 4; // CraftBukkit - add field
+ public boolean isIncendiary = false; // CraftBukkit - add field
2019-04-23 12:00:00 +10:00
public EntityTNTPrimed(EntityTypes<? extends EntityTNTPrimed> entitytypes, World world) {
super(entitytypes, world);
2019-12-11 09:00:00 +11:00
@@ -57,10 +60,13 @@
2019-04-23 12:00:00 +10:00
--this.fuseTicks;
if (this.fuseTicks <= 0) {
- this.die();
+ // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
+ // this.die();
2015-02-26 22:41:06 +00:00
if (!this.world.isClientSide) {
this.explode();
}
+ this.die();
+ // CraftBukkit end
} else {
2020-08-12 07:00:00 +10:00
this.aJ();
2019-12-11 09:00:00 +11:00
if (this.world.isClientSide) {
@@ -71,9 +77,16 @@
}
private void explode() {
- float f = 4.0F;
+ // CraftBukkit start
+ // float f = 4.0F;
2015-02-26 22:41:06 +00:00
2019-12-11 09:00:00 +11:00
- this.world.explode(this, this.locX(), this.e(0.0625D), this.locZ(), 4.0F, Explosion.Effect.BREAK);
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
2019-12-11 09:00:00 +11:00
+ this.world.createExplosion(this, this.locX(), this.e(0.0625D), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK);
+ }
+ // CraftBukkit end
}
2019-04-23 12:00:00 +10:00
@Override