2015-05-25 18:37:24 +08:00
|
|
|
--- a/net/minecraft/server/EntityCreeper.java
|
|
|
|
+++ b/net/minecraft/server/EntityCreeper.java
|
2014-11-26 05:32:16 +08:00
|
|
|
@@ -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 {
|
|
|
|
|
2015-02-27 06:41:06 +08:00
|
|
|
private int a;
|
2014-11-26 05:32:16 +08:00
|
|
|
@@ -7,6 +12,7 @@
|
|
|
|
private int maxFuseTicks = 30;
|
|
|
|
private int explosionRadius = 3;
|
2015-02-27 06:41:06 +08:00
|
|
|
private int bn = 0;
|
2014-11-26 05:32:16 +08:00
|
|
|
+ private int record = -1; // CraftBukkit
|
|
|
|
|
|
|
|
public EntityCreeper(World world) {
|
|
|
|
super(world);
|
2015-04-13 18:47:47 +08:00
|
|
|
@@ -110,19 +116,39 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void die(DamageSource damagesource) {
|
|
|
|
- super.die(damagesource);
|
|
|
|
+ // super.die(damagesource); // CraftBukkit - Moved to end
|
|
|
|
if (damagesource.getEntity() instanceof EntitySkeleton) {
|
|
|
|
int i = Item.getId(Items.RECORD_13);
|
|
|
|
int j = Item.getId(Items.RECORD_WAIT);
|
|
|
|
int k = i + this.random.nextInt(j - i + 1);
|
|
|
|
|
|
|
|
- this.a(Item.getById(k), 1);
|
|
|
|
+ // CraftBukkit start - Store record for now, drop in dropDeathLoot
|
|
|
|
+ // this.a(Item.getById(k), 1);
|
|
|
|
+ this.record = k;
|
|
|
|
+ // CraftBukkit end
|
2015-02-27 06:41:06 +08:00
|
|
|
} else if (damagesource.getEntity() instanceof EntityCreeper && damagesource.getEntity() != this && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).cp()) {
|
|
|
|
((EntityCreeper) damagesource.getEntity()).cq();
|
2015-04-13 18:47:47 +08:00
|
|
|
- this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ // this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
|
|
|
|
+ headDrop = new ItemStack(Items.SKULL, 1, 4);
|
|
|
|
+ // CraftBukkit end
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ super.die(damagesource); // CraftBukkit - Moved from above
|
|
|
|
+ }
|
2015-02-27 06:41:06 +08:00
|
|
|
+
|
2014-11-26 05:32:16 +08:00
|
|
|
+ // CraftBukkit start - Whole method
|
|
|
|
+ @Override
|
|
|
|
+ protected void dropDeathLoot(boolean flag, int i) {
|
|
|
|
+ super.dropDeathLoot(flag, i);
|
2015-02-27 06:41:06 +08:00
|
|
|
|
2014-11-26 05:32:16 +08:00
|
|
|
+ // Drop a music disc?
|
|
|
|
+ if (this.record != -1) {
|
|
|
|
+ this.a(Item.getById(this.record), 1);
|
|
|
|
+ this.record = -1;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
public boolean r(Entity entity) {
|
|
|
|
return true;
|
2015-04-13 18:47:47 +08:00
|
|
|
@@ -146,7 +172,21 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
|
|
|
|
public void onLightningStrike(EntityLightning entitylightning) {
|
|
|
|
super.onLightningStrike(entitylightning);
|
|
|
|
- this.datawatcher.watch(17, Byte.valueOf((byte) 1));
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.setPowered(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setPowered(boolean powered) {
|
|
|
|
+ if (!powered) {
|
|
|
|
+ this.datawatcher.watch(17, Byte.valueOf((byte) 0));
|
|
|
|
+ } else {
|
|
|
|
+ this.datawatcher.watch(17, Byte.valueOf((byte) 1));
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
protected boolean a(EntityHuman entityhuman) {
|
2015-04-13 18:47:47 +08:00
|
|
|
@@ -170,8 +210,15 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
|
|
|
|
float f = this.isPowered() ? 2.0F : 1.0F;
|
2015-02-27 06:41:06 +08:00
|
|
|
|
2014-11-26 05:32:16 +08:00
|
|
|
- this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, flag);
|
|
|
|
- this.die();
|
|
|
|
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag);
|
|
|
|
+ this.die();
|
|
|
|
+ } else {
|
|
|
|
+ fuseTicks = 0;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|