craftbukkit/nms-patches/net/minecraft/world/entity/item/EntityTNTPrimed.patch

54 lines
2 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/item/EntityTNTPrimed.java
+++ b/net/minecraft/world/entity/item/EntityTNTPrimed.java
@@ -17,12 +17,16 @@
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.World;
2016-11-17 12:41:03 +11:00
2021-03-09 08:47:33 +11:00
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+
public class EntityTNTPrimed extends Entity {
2021-11-22 09:00:00 +11:00
private static final DataWatcherObject<Integer> DATA_FUSE_ID = DataWatcher.defineId(EntityTNTPrimed.class, DataWatcherRegistry.INT);
2021-06-11 15:00:00 +10:00
private static final int DEFAULT_FUSE_TIME = 80;
2016-11-17 12:41:03 +11:00
@Nullable
2021-06-11 15:00:00 +10:00
public EntityLiving owner;
+ 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);
2021-06-11 15:00:00 +10:00
@@ -73,10 +77,13 @@
2021-11-22 09:00:00 +11:00
this.setFuse(i);
2021-06-11 15:00:00 +10:00
if (i <= 0) {
2021-11-22 09:00:00 +11:00
- this.discard();
+ // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
2021-11-22 09:00:00 +11:00
+ // this.discard();
2021-06-11 15:00:00 +10:00
if (!this.level.isClientSide) {
this.explode();
}
2021-11-22 09:00:00 +11:00
+ this.discard();
+ // CraftBukkit end
} else {
2021-11-22 09:00:00 +11:00
this.updateInWaterStateAndDoFluidPushing();
2021-06-11 15:00:00 +10:00
if (this.level.isClientSide) {
@@ -87,9 +94,16 @@
}
private void explode() {
- float f = 4.0F;
+ // CraftBukkit start
+ // float f = 4.0F;
2015-02-26 22:41:06 +00:00
2021-11-22 09:00:00 +11:00
- this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, Explosion.Effect.BREAK);
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
2021-11-22 09:00:00 +11:00
+ this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK);
+ }
+ // CraftBukkit end
}
2019-04-23 12:00:00 +10:00
@Override