PaperMC/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLargeFireball.patch
CraftBukkit/Spigot 43702a9e10 Update to Minecraft 1.18-pre5
By: md_5 <git@md-5.net>
2021-11-22 09:00:00 +11:00

51 lines
2.5 KiB
Diff

--- a/net/minecraft/world/entity/projectile/EntityLargeFireball.java
+++ b/net/minecraft/world/entity/projectile/EntityLargeFireball.java
@@ -11,17 +11,21 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionEntity;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+
public class EntityLargeFireball extends EntityFireballFireball {
public int explosionPower = 1;
public EntityLargeFireball(EntityTypes<? extends EntityLargeFireball> entitytypes, World world) {
super(entitytypes, world);
+ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit
}
public EntityLargeFireball(World world, EntityLiving entityliving, double d0, double d1, double d2, int i) {
super(EntityTypes.FIREBALL, entityliving, d0, d1, d2, world);
this.explosionPower = i;
+ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit
}
@Override
@@ -30,7 +34,15 @@
if (!this.level.isClientSide) {
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
- this.level.explode((Entity) null, this.getX(), this.getY(), this.getZ(), (float) this.explosionPower, flag, flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE);
+ // CraftBukkit start - fire ExplosionPrimeEvent
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ // give 'this' instead of (Entity) null so we know what causes the damage
+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE);
+ }
+ // CraftBukkit end
this.discard();
}
@@ -61,7 +73,8 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("ExplosionPower", 99)) {
- this.explosionPower = nbttagcompound.getByte("ExplosionPower");
+ // CraftBukkit - set bukkitYield when setting explosionpower
+ bukkitYield = this.explosionPower = nbttagcompound.getByte("ExplosionPower");
}
}