3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 13:00:06 +01:00
Paper/nms-patches/EntityTNTPrimed.patch

54 Zeilen
1.9 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityTNTPrimed.java
+++ b/net/minecraft/server/EntityTNTPrimed.java
2016-11-17 02:41:03 +01:00
@@ -1,6 +1,7 @@
package net.minecraft.server;
2016-11-17 02:41:03 +01:00
import javax.annotation.Nullable;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
2016-11-17 02:41:03 +01:00
public class EntityTNTPrimed extends Entity {
2016-11-17 02:41:03 +01:00
@@ -8,6 +9,8 @@
@Nullable
private EntityLiving source;
2019-04-23 04:00:00 +02:00
private int fuseTicks;
+ public float yield = 4; // CraftBukkit - add field
+ public boolean isIncendiary = false; // CraftBukkit - add field
2019-04-23 04:00:00 +02:00
public EntityTNTPrimed(EntityTypes<? extends EntityTNTPrimed> entitytypes, World world) {
super(entitytypes, world);
@@ -60,10 +63,13 @@
2019-04-23 04:00:00 +02: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 23:41:06 +01:00
if (!this.world.isClientSide) {
this.explode();
}
+ this.die();
+ // CraftBukkit end
} else {
2019-06-21 12:00:00 +02:00
this.ay();
2019-04-23 04:00:00 +02:00
this.world.addParticle(Particles.SMOKE, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
@@ -72,9 +78,16 @@
}
private void explode() {
- float f = 4.0F;
+ // CraftBukkit start
+ // float f = 4.0F;
2015-02-26 23:41:06 +01:00
2019-04-23 04:00:00 +02:00
- this.world.explode(this, this.locX, this.locY + (double) (this.getHeight() / 16.0F), 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-04-23 04:00:00 +02:00
+ this.world.createExplosion(this, this.locX, this.locY + (double) (this.getHeight() / 16.0F), this.locZ, event.getRadius(), event.getFire(), Explosion.Effect.BREAK);
+ }
+ // CraftBukkit end
}
2019-04-23 04:00:00 +02:00
@Override