91 lines
3.8 KiB
Diff
91 lines
3.8 KiB
Diff
--- a/net/minecraft/world/entity/projectile/EntityFireworks.java
|
|
+++ b/net/minecraft/world/entity/projectile/EntityFireworks.java
|
|
@@ -29,15 +29,17 @@
|
|
import net.minecraft.world.phys.MovingObjectPositionEntity;
|
|
import net.minecraft.world.phys.Vec3D;
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
+
|
|
public class EntityFireworks extends IProjectile implements ItemSupplier {
|
|
|
|
public static final DataWatcherObject<ItemStack> DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK);
|
|
private static final DataWatcherObject<OptionalInt> DATA_ATTACHED_TO_TARGET = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.OPTIONAL_UNSIGNED_INT);
|
|
public static final DataWatcherObject<Boolean> DATA_SHOT_AT_ANGLE = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.BOOLEAN);
|
|
- private int life;
|
|
+ public int life; // PAIL private -> public
|
|
public int lifetime;
|
|
@Nullable
|
|
- private EntityLiving attachedToEntity;
|
|
+ public EntityLiving attachedToEntity; // PAIL private -> public
|
|
|
|
public EntityFireworks(EntityTypes<? extends EntityFireworks> entitytypes, World world) {
|
|
super(entitytypes, world);
|
|
@@ -144,7 +146,7 @@
|
|
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity);
|
|
|
|
if (!this.noPhysics) {
|
|
- this.onHit(movingobjectposition);
|
|
+ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event
|
|
this.hasImpulse = true;
|
|
}
|
|
|
|
@@ -159,7 +161,11 @@
|
|
}
|
|
|
|
if (!this.level.isClientSide && this.life > this.lifetime) {
|
|
- this.explode();
|
|
+ // CraftBukkit start
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
|
|
+ this.explode();
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
}
|
|
@@ -175,7 +181,11 @@
|
|
protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {
|
|
super.onHitEntity(movingobjectpositionentity);
|
|
if (!this.level.isClientSide) {
|
|
- this.explode();
|
|
+ // CraftBukkit start
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
|
|
+ this.explode();
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
|
|
@@ -185,7 +195,11 @@
|
|
|
|
this.level.getBlockState(blockposition).entityInside(this.level, blockposition, this);
|
|
if (!this.level.isClientSide() && this.hasExplosion()) {
|
|
- this.explode();
|
|
+ // CraftBukkit start
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
|
|
+ this.explode();
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
super.onHitBlock(movingobjectpositionblock);
|
|
@@ -211,7 +225,9 @@
|
|
|
|
if (f > 0.0F) {
|
|
if (this.attachedToEntity != null) {
|
|
+ CraftEventFactory.entityDamage = this; // CraftBukkit
|
|
this.attachedToEntity.hurt(DamageSource.fireworks(this, this.getOwner()), 5.0F + (float) (nbttaglist.size() * 2));
|
|
+ CraftEventFactory.entityDamage = null; // CraftBukkit
|
|
}
|
|
|
|
double d0 = 5.0D;
|
|
@@ -238,7 +254,9 @@
|
|
if (flag) {
|
|
float f1 = f * (float) Math.sqrt((5.0D - (double) this.distanceTo(entityliving)) / 5.0D);
|
|
|
|
+ CraftEventFactory.entityDamage = this; // CraftBukkit
|
|
entityliving.hurt(DamageSource.fireworks(this, this.getOwner()), f1);
|
|
+ CraftEventFactory.entityDamage = null; // CraftBukkit
|
|
}
|
|
}
|
|
}
|