3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00
Paper/nms-patches/EntityCreeper.patch

76 Zeilen
3.0 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityCreeper.java
+++ b/net/minecraft/server/EntityCreeper.java
2019-07-03 03:10:51 +02:00
@@ -2,6 +2,11 @@
2019-04-23 04:00:00 +02:00
2016-11-17 02:41:03 +01:00
import java.util.Collection;
import java.util.Iterator;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
2019-07-03 03:10:51 +02:00
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
2016-05-10 13:47:39 +02:00
public class EntityCreeper extends EntityMonster {
2020-06-25 02:00:00 +02:00
@@ -165,9 +170,19 @@
2019-04-23 04:00:00 +02:00
@Override
public void onLightningStrike(EntityLightning entitylightning) {
super.onLightningStrike(entitylightning);
2019-04-23 04:00:00 +02:00
- 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);
}
2016-05-31 12:53:37 +02:00
+ public void setPowered(boolean powered) {
2019-04-23 04:00:00 +02:00
+ this.datawatcher.set(EntityCreeper.POWERED, powered);
2016-05-31 12:53:37 +02:00
+ }
+ // CraftBukkit end
+
2019-04-23 04:00:00 +02:00
@Override
2020-06-25 02:00:00 +02:00
protected EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) {
2016-11-17 02:41:03 +01:00
ItemStack itemstack = entityhuman.b(enumhand);
2020-06-25 02:00:00 +02:00
@@ -192,10 +207,18 @@
2019-06-21 12:00:00 +02:00
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;
2015-02-26 23:41:06 +01:00
2018-12-13 01:00:00 +01:00
- this.killed = true;
2019-12-10 23:00:00 +01:00
- this.world.explode(this, this.locX(), this.locY(), this.locZ(), (float) this.explosionRadius * f, explosion_effect);
- this.die();
2018-12-13 01:00:00 +01:00
- this.createEffectCloud();
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
+ this.world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
2018-12-13 01:00:00 +01:00
+ this.killed = true;
2019-12-10 23:00:00 +01:00
+ this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect);
+ this.die();
2018-12-13 01:00:00 +01:00
+ this.createEffectCloud();
+ } else {
+ fuseTicks = 0;
+ }
+ // CraftBukkit end
}
}
2020-06-25 02:00:00 +02:00
@@ -206,6 +229,7 @@
if (!collection.isEmpty()) {
2019-12-10 23:00:00 +01:00
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);
2020-06-25 02:00:00 +02:00
@@ -219,7 +243,7 @@
2019-07-20 01:00:00 +02:00
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
2019-07-03 03:10:51 +02:00
}
- this.world.addEntity(entityareaeffectcloud);
+ this.world.addEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
}
}