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

71 Zeilen
2.6 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityCreeper.java
+++ b/net/minecraft/server/EntityCreeper.java
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityCreeper extends EntityMonster {
2016-02-29 22:32:46 +01:00
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.b);
2016-03-07 09:51:42 +01:00
@@ -117,7 +122,7 @@
}
public void die(DamageSource damagesource) {
- super.die(damagesource);
+ // super.die(damagesource); // CraftBukkit - Moved to end
2016-02-29 22:32:46 +01:00
if (this.world.getGameRules().getBoolean("doMobLoot")) {
if (damagesource.getEntity() instanceof EntitySkeleton) {
int i = Item.getId(Items.RECORD_13);
2016-03-07 09:51:42 +01:00
@@ -130,6 +135,7 @@
this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
2016-02-29 22:32:46 +01:00
}
}
+ super.die(damagesource); // CraftBukkit - Moved from above
2016-03-07 09:51:42 +01:00
}
2016-03-07 09:51:42 +01:00
@@ -155,8 +161,18 @@
public void onLightningStrike(EntityLightning entitylightning) {
super.onLightningStrike(entitylightning);
+ // CraftBukkit start
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
+ return;
+ }
+
+ this.setPowered(true);
+ }
+
+ public void setPowered(boolean powered) {
2016-02-29 22:32:46 +01:00
this.datawatcher.set(EntityCreeper.b, Boolean.valueOf(true));
}
2016-02-29 22:32:46 +01:00
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
protected boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
if (itemstack != null && itemstack.getItem() == Items.FLINT_AND_STEEL) {
2016-03-07 09:51:42 +01:00
@@ -177,9 +193,17 @@
boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
float f = this.isPowered() ? 2.0F : 1.0F;
2015-02-26 23:41:06 +01:00
2016-02-29 22:32:46 +01:00
- this.aT = true;
- this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, flag);
- this.die();
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()) {
2016-02-29 22:32:46 +01:00
+ this.aT = true;
+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag);
+ this.die();
+ } else {
+ fuseTicks = 0;
+ }
+ // CraftBukkit end
}
}