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
2023-06-24 09:15:05 +02:00
+// CraftBukkit start;
2019-07-03 03:10:51 +02:00
+import org.bukkit.event.entity.CreatureSpawnEvent;
2023-06-24 09:15:05 +02:00
+import org.bukkit.craftbukkit.event.CraftEventFactory;
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);
2023-06-24 09:15:05 +02:00
@@ -218,9 +224,20 @@
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);
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
+ return;
+ }
2023-06-24 09:15:05 +02:00
+ // CraftBukkit end
this.entityData.set(EntityCreeper.DATA_IS_POWERED, true);
2014-11-25 22:32:16 +01:00
}
2023-06-24 09:15:05 +02:00
+ // CraftBukkit start
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);
2023-12-16 23:29:44 +01:00
@@ -231,7 +248,7 @@
this.level().playSound(entityhuman, this.getX(), this.getY(), this.getZ(), soundeffect, this.getSoundSource(), 1.0F, this.random.nextFloat() * 0.4F + 0.8F);
if (!this.level().isClientSide) {
this.ignite();
- if (!itemstack.isDamageableItem()) {
+ if (itemstack.getItem().getMaxDamage() == 0) { // CraftBukkit - fix MC-264285: unbreakable flint and steels are completely consumed when igniting a creeper
itemstack.shrink(1);
} else {
itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
2023-06-24 09:15:05 +02:00
@@ -250,10 +267,19 @@
2023-06-07 17:30:00 +02: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
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start
2023-06-24 09:15:05 +02:00
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent(this, this.explosionRadius * f, false);
2014-11-25 22:32:16 +01:00
+ if (!event.isCancelled()) {
2023-06-24 09:15:05 +02:00
+ // CraftBukkit end
this.dead = true;
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
this.discard();
this.spawnLingeringCloud();
+ // CraftBukkit start
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
}
}
2023-06-24 09:15:05 +02:00
@@ -264,6 +290,7 @@
2017-07-22 01:51:22 +02:00
if (!collection.isEmpty()) {
2023-06-07 17:30:00 +02: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);
2023-06-24 09:15:05 +02:00
@@ -277,7 +304,7 @@
2019-07-20 01:00:00 +02:00
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
2019-07-03 03:10:51 +02:00
}
2023-06-07 17:30:00 +02:00
- this.level().addFreshEntity(entityareaeffectcloud);
+ this.level().addFreshEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
2019-07-03 03:10:51 +02:00
}
}