2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/monster/EntityCreeper.java
|
|
|
|
+++ b/net/minecraft/world/entity/monster/EntityCreeper.java
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -43,6 +43,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-11-21 23:00:00 +01:00
|
|
|
private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT);
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -218,9 +224,19 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2021-11-21 23:00:00 +01:00
|
|
|
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
|
|
|
|
super.thunderHit(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
|
2021-11-21 23:00:00 +01:00
|
|
|
protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) {
|
|
|
|
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -246,10 +262,18 @@
|
2022-12-07 17:00:00 +01:00
|
|
|
if (!this.level.isClientSide) {
|
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;
|
2022-12-07 17:00:00 +01:00
|
|
|
- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
|
2021-11-21 23:00:00 +01:00
|
|
|
- this.discard();
|
|
|
|
- this.spawnLingeringCloud();
|
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;
|
2022-12-07 17:00:00 +01:00
|
|
|
+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
|
2021-11-21 23:00:00 +01:00
|
|
|
+ this.discard();
|
|
|
|
+ this.spawnLingeringCloud();
|
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-11-21 23:00:00 +01:00
|
|
|
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level, this.getX(), this.getY(), this.getZ());
|
2017-07-22 01:51:22 +02:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
+ entityareaeffectcloud.setOwner(this); // CraftBukkit
|
2017-07-22 01:51:22 +02:00
|
|
|
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-11-21 23:00:00 +01:00
|
|
|
- this.level.addFreshEntity(entityareaeffectcloud);
|
|
|
|
+ this.level.addFreshEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
|
2019-07-03 03:10:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|