craftbukkit/nms-patches/net/minecraft/world/entity/monster/EntityCreeper.patch

77 lines
3.3 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/monster/EntityCreeper.java
+++ b/net/minecraft/world/entity/monster/EntityCreeper.java
2021-06-11 15:00:00 +10:00
@@ -44,6 +44,12 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.level.World;
2021-06-11 15:00:00 +10:00
import net.minecraft.world.level.gameevent.GameEvent;
2021-03-09 08:47:33 +11:00
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
2019-07-03 11:10:51 +10:00
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
2021-03-09 08:47:33 +11:00
+
2021-06-11 15:00:00 +10:00
public class EntityCreeper extends EntityMonster implements PowerableMob {
2021-11-22 09:00:00 +11:00
private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT);
2021-06-11 15:00:00 +10:00
@@ -219,9 +225,19 @@
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
super.thunderHit(worldserver, entitylightning);
2021-06-11 15:00:00 +10:00
- 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);
}
2016-05-31 20:53:37 +10:00
+ public void setPowered(boolean powered) {
2021-06-11 15:00:00 +10:00
+ this.entityData.set(EntityCreeper.DATA_IS_POWERED, powered);
2016-05-31 20:53:37 +10:00
+ }
+ // CraftBukkit end
+
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
2021-06-11 15:00:00 +10:00
@@ -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;
2015-02-26 22:41:06 +00:00
2021-06-11 15:00:00 +10:00
- this.dead = true;
2021-11-22 09:00:00 +11:00
- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, explosion_effect);
- this.discard();
- this.spawnLingeringCloud();
2016-03-01 08:32:46 +11:00
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
2021-06-11 15:00:00 +10:00
+ this.dead = true;
2021-11-22 09:00:00 +11:00
+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), explosion_effect);
+ this.discard();
+ this.spawnLingeringCloud();
+ } else {
2021-06-11 15:00:00 +10:00
+ swell = 0;
+ }
+ // CraftBukkit end
}
}
2021-06-11 15:00:00 +10:00
@@ -260,6 +284,7 @@
if (!collection.isEmpty()) {
2021-11-22 09:00:00 +11:00
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level, this.getX(), this.getY(), this.getZ());
2021-11-22 09:00:00 +11:00
+ entityareaeffectcloud.setOwner(this); // CraftBukkit
entityareaeffectcloud.setRadius(2.5F);
entityareaeffectcloud.setRadiusOnUse(-0.5F);
entityareaeffectcloud.setWaitTime(10);
2021-06-11 15:00:00 +10:00
@@ -273,7 +298,7 @@
2019-07-20 09:00:00 +10:00
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
2019-07-03 11:10:51 +10:00
}
2021-11-22 09:00:00 +11:00
- this.level.addFreshEntity(entityareaeffectcloud);
+ this.level.addFreshEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
2019-07-03 11:10:51 +10:00
}
}