Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/nms-patches/EntityCreeper.patch
2019-12-11 09:00:00 +11:00

76 Zeilen
3.0 KiB
Diff

--- a/net/minecraft/server/EntityCreeper.java
+++ b/net/minecraft/server/EntityCreeper.java
@@ -2,6 +2,11 @@
import java.util.Collection;
import java.util.Iterator;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
public class EntityCreeper extends EntityMonster {
@@ -167,9 +172,19 @@
@Override
public void onLightningStrike(EntityLightning entitylightning) {
super.onLightningStrike(entitylightning);
- this.datawatcher.set(EntityCreeper.POWERED, true);
+ // CraftBukkit start
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
+ return;
+ }
+
+ this.setPowered(true);
}
+ public void setPowered(boolean powered) {
+ this.datawatcher.set(EntityCreeper.POWERED, powered);
+ }
+ // CraftBukkit end
+
@Override
protected boolean a(EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
@@ -194,10 +209,18 @@
Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
float f = this.isPowered() ? 2.0F : 1.0F;
- this.killed = true;
- this.world.explode(this, this.locX(), this.locY(), this.locZ(), (float) this.explosionRadius * f, explosion_effect);
- this.die();
- this.createEffectCloud();
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
+ this.world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ this.killed = true;
+ this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect);
+ this.die();
+ this.createEffectCloud();
+ } else {
+ fuseTicks = 0;
+ }
+ // CraftBukkit end
}
}
@@ -208,6 +231,7 @@
if (!collection.isEmpty()) {
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX(), this.locY(), this.locZ());
+ entityareaeffectcloud.setSource(this); // CraftBukkit
entityareaeffectcloud.setRadius(2.5F);
entityareaeffectcloud.setRadiusOnUse(-0.5F);
entityareaeffectcloud.setWaitTime(10);
@@ -221,7 +245,7 @@
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
}
- this.world.addEntity(entityareaeffectcloud);
+ this.world.addEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
}
}