--- a/net/minecraft/world/entity/projectile/EntityFireworks.java +++ b/net/minecraft/world/entity/projectile/EntityFireworks.java @@ -35,6 +35,10 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.event.entity.EntityRemoveEvent; +// CraftBukkit end + public class EntityFireworks extends IProjectile implements ItemSupplier { public static final DataWatcherObject DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK); @@ -163,7 +167,7 @@ } if (!this.noPhysics && this.isAlive() && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { - this.hitTargetOrDeflectSelf(movingobjectposition); + this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event this.hasImpulse = true; } @@ -183,7 +187,11 @@ if (world instanceof WorldServer) { WorldServer worldserver = (WorldServer) world; - this.explode(worldserver); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { + this.explode(worldserver); + } + // CraftBukkit end } } @@ -193,7 +201,7 @@ worldserver.broadcastEntityEvent(this, (byte) 17); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); this.dealExplosionDamage(worldserver); - this.discard(); + this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause } @Override @@ -202,7 +210,11 @@ World world = this.level(); if (world instanceof WorldServer worldserver) { - this.explode(worldserver); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { + this.explode(worldserver); + } + // CraftBukkit end } } @@ -216,7 +228,11 @@ if (world instanceof WorldServer worldserver) { if (this.hasExplosion()) { - this.explode(worldserver); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { + this.explode(worldserver); + } + // CraftBukkit end } }