mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
1128edadb2
By: Doc <nachito94@msn.com>
96 lines
4.4 KiB
Diff
96 lines
4.4 KiB
Diff
--- a/net/minecraft/world/entity/monster/EntityCreeper.java
|
|
+++ b/net/minecraft/world/entity/monster/EntityCreeper.java
|
|
@@ -43,6 +43,13 @@
|
|
import net.minecraft.world.level.World;
|
|
import net.minecraft.world.level.gameevent.GameEvent;
|
|
|
|
+// CraftBukkit start;
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.entity.EntityRemoveEvent;
|
|
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class EntityCreeper extends EntityMonster implements PowerableMob {
|
|
|
|
private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT);
|
|
@@ -53,6 +60,7 @@
|
|
public int maxSwell = 30;
|
|
public int explosionRadius = 3;
|
|
private int droppedSkulls;
|
|
+ public Entity entityIgniter; // CraftBukkit
|
|
|
|
public EntityCreeper(EntityTypes<? extends EntityCreeper> entitytypes, World world) {
|
|
super(entitytypes, world);
|
|
@@ -216,9 +224,20 @@
|
|
@Override
|
|
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
|
|
super.thunderHit(worldserver, entitylightning);
|
|
+ // CraftBukkit start
|
|
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
this.entityData.set(EntityCreeper.DATA_IS_POWERED, true);
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ public void setPowered(boolean powered) {
|
|
+ this.entityData.set(EntityCreeper.DATA_IS_POWERED, powered);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
@Override
|
|
protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) {
|
|
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
|
@@ -228,8 +247,9 @@
|
|
|
|
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.entityIgniter = entityhuman; // CraftBukkit
|
|
this.ignite();
|
|
- if (!itemstack.isDamageableItem()) {
|
|
+ if (itemstack.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, getSlotForHand(enumhand));
|
|
@@ -246,11 +266,20 @@
|
|
if (!this.level().isClientSide) {
|
|
float f = this.isPowered() ? 2.0F : 1.0F;
|
|
|
|
+ // CraftBukkit start
|
|
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent(this, this.explosionRadius * f, false);
|
|
+ if (!event.isCancelled()) {
|
|
+ // 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, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customCausingEntityDamager(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
|
|
this.spawnLingeringCloud();
|
|
this.triggerOnDeathMobEffects(Entity.RemovalReason.KILLED);
|
|
- this.discard();
|
|
+ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
|
|
+ // CraftBukkit start
|
|
+ } else {
|
|
+ swell = 0;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
}
|
|
@@ -261,6 +290,7 @@
|
|
if (!collection.isEmpty()) {
|
|
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
|
|
|
|
+ entityareaeffectcloud.setOwner(this); // CraftBukkit
|
|
entityareaeffectcloud.setRadius(2.5F);
|
|
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
|
entityareaeffectcloud.setWaitTime(10);
|
|
@@ -274,7 +304,7 @@
|
|
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
|
|
}
|
|
|
|
- this.level().addFreshEntity(entityareaeffectcloud);
|
|
+ this.level().addFreshEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
|
|
}
|
|
|
|
}
|