2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/monster/EntityCreeper.java
|
|
|
|
+++ b/net/minecraft/world/entity/monster/EntityCreeper.java
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -44,6 +44,12 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.World;
|
2021-06-11 07:00:00 +02:00
|
|
|
import net.minecraft.world.level.gameevent.GameEvent;
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2019-07-03 03:10:51 +02:00
|
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +01:00
|
|
|
+
|
2021-06-11 07:00:00 +02:00
|
|
|
public class EntityCreeper extends EntityMonster implements PowerableMob {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.INT);
|
|
|
|
@@ -219,9 +225,19 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2020-08-11 23:00:00 +02:00
|
|
|
public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) {
|
|
|
|
super.onLightningStrike(worldserver, entitylightning);
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.entityData.set(EntityCreeper.DATA_IS_POWERED, true);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.setPowered(true);
|
|
|
|
}
|
|
|
|
|
2016-05-31 12:53:37 +02:00
|
|
|
+ public void setPowered(boolean powered) {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.entityData.set(EntityCreeper.DATA_IS_POWERED, powered);
|
2016-05-31 12:53:37 +02:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2020-06-25 02:00:00 +02:00
|
|
|
protected EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) {
|
2016-11-17 02:41:03 +01:00
|
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -246,10 +262,18 @@
|
|
|
|
Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
|
2014-11-25 22:32:16 +01:00
|
|
|
float f = this.isPowered() ? 2.0F : 1.0F;
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.dead = true;
|
|
|
|
- this.level.explode(this, this.locX(), this.locY(), this.locZ(), (float) this.explosionRadius * f, explosion_effect);
|
2014-11-25 22:32:16 +01:00
|
|
|
- this.die();
|
2018-12-13 01:00:00 +01:00
|
|
|
- this.createEffectCloud();
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start
|
2014-11-25 22:32:16 +01:00
|
|
|
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
|
2021-06-11 13:33:49 +02:00
|
|
|
+ this.level.getCraftServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (!event.isCancelled()) {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.dead = true;
|
|
|
|
+ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.die();
|
2018-12-13 01:00:00 +01:00
|
|
|
+ this.createEffectCloud();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ swell = 0;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -260,6 +284,7 @@
|
2017-07-22 01:51:22 +02:00
|
|
|
if (!collection.isEmpty()) {
|
2021-06-11 07:00:00 +02:00
|
|
|
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level, this.locX(), this.locY(), this.locZ());
|
2017-07-22 01:51:22 +02:00
|
|
|
|
|
|
|
+ entityareaeffectcloud.setSource(this); // CraftBukkit
|
|
|
|
entityareaeffectcloud.setRadius(2.5F);
|
|
|
|
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
|
|
|
entityareaeffectcloud.setWaitTime(10);
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -273,7 +298,7 @@
|
2019-07-20 01:00:00 +02:00
|
|
|
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
|
2019-07-03 03:10:51 +02:00
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.level.addEntity(entityareaeffectcloud);
|
|
|
|
+ this.level.addEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
|
2019-07-03 03:10:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|