Paper/nms-patches/EntityFireworks.patch

51 Zeilen
2.1 KiB
Diff

--- a/net/minecraft/server/EntityFireworks.java
+++ b/net/minecraft/server/EntityFireworks.java
@@ -3,12 +3,13 @@
import java.util.Iterator;
import java.util.List;
import java.util.OptionalInt;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
public class EntityFireworks extends Entity implements IProjectile {
public static final DataWatcherObject<ItemStack> FIREWORK_ITEM = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.g);
private static final DataWatcherObject<OptionalInt> c = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.r);
- private static final DataWatcherObject<Boolean> d = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.i);
+ public static final DataWatcherObject<Boolean> d = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.i); // PAIL
private int ticksFlown;
public int expectedLifespan;
private EntityLiving ridingEntity;
@@ -133,7 +134,11 @@
}
if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) {
- this.explode();
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
+ this.explode();
+ }
+ // CraftBukkit end
}
}
@@ -184,7 +189,9 @@
if (f > 0.0F) {
if (this.ridingEntity != null) {
+ CraftEventFactory.entityDamage = this; // CraftBukkit
this.ridingEntity.damageEntity(DamageSource.FIREWORKS, 5.0F + (float) (nbttaglist.size() * 2));
+ CraftEventFactory.entityDamage = null; // CraftBukkit
}
double d0 = 5.0D;
@@ -211,7 +218,9 @@
if (flag) {
float f1 = f * (float) Math.sqrt((5.0D - (double) this.g(entityliving)) / 5.0D);
+ CraftEventFactory.entityDamage = this; // CraftBukkit
entityliving.damageEntity(DamageSource.FIREWORKS, f1);
+ CraftEventFactory.entityDamage = null; // CraftBukkit
}
}
}