2024-10-23 02:15:00 +11:00

71 lines
2.6 KiB
Diff

--- a/net/minecraft/world/entity/projectile/EntityFireworks.java
+++ b/net/minecraft/world/entity/projectile/EntityFireworks.java
@@ -33,6 +33,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<ItemStack> DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK);
@@ -152,7 +156,7 @@
}
if (!this.noPhysics && this.isAlive() && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
- this.hitTargetOrDeflectSelf(movingobjectposition);
+ this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event
this.hasImpulse = true;
}
@@ -172,7 +176,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
}
}
@@ -182,7 +190,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
@@ -191,7 +199,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
}
}
@@ -205,7 +217,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
}
}