--- a/net/minecraft/world/entity/monster/EntityCreeper.java +++ b/net/minecraft/world/entity/monster/EntityCreeper.java @@ -44,6 +44,12 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +// CraftBukkit end + public class EntityCreeper extends EntityMonster implements PowerableMob { private static final DataWatcherObject DATA_SWELL_DIR = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.INT); @@ -219,9 +225,19 @@ @Override public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { super.onLightningStrike(worldserver, entitylightning); - this.entityData.set(EntityCreeper.DATA_IS_POWERED, true); + // CraftBukkit start + if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { + return; + } + + this.setPowered(true); } + public void setPowered(boolean powered) { + this.entityData.set(EntityCreeper.DATA_IS_POWERED, powered); + } + // CraftBukkit end + @Override protected EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); @@ -246,10 +262,18 @@ Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; float f = this.isPowered() ? 2.0F : 1.0F; - this.dead = true; - this.level.explode(this, this.locX(), this.locY(), this.locZ(), (float) this.explosionRadius * f, explosion_effect); - this.die(); - this.createEffectCloud(); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false); + this.level.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + this.dead = true; + this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect); + this.die(); + this.createEffectCloud(); + } else { + swell = 0; + } + // CraftBukkit end } } @@ -260,6 +284,7 @@ if (!collection.isEmpty()) { EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level, this.locX(), this.locY(), this.locZ()); + entityareaeffectcloud.setSource(this); // CraftBukkit entityareaeffectcloud.setRadius(2.5F); entityareaeffectcloud.setRadiusOnUse(-0.5F); entityareaeffectcloud.setWaitTime(10); @@ -273,7 +298,7 @@ entityareaeffectcloud.addEffect(new MobEffect(mobeffect)); } - this.level.addEntity(entityareaeffectcloud); + this.level.addEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit } }