diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java new file mode 100644 index 0000000000..0ab89a59e1 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityCreeper.java @@ -0,0 +1,116 @@ +package net.minecraft.server; + +//CraftBukkit start +import org.bukkit.Server; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.event.entity.ExplosionPrimedEvent; +// CraftBukkit end + +public class EntityCreeper extends EntityMonster { + + int a; + int b; + + public EntityCreeper(World world) { + super(world); + this.texture = "/mob/creeper.png"; + } + + protected void a() { + super.a(); + this.datawatcher.a(16, Byte.valueOf((byte) -1)); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + } + + public void b_() { + this.b = this.a; + if (this.world.isStatic) { + int i = this.K(); + + if (i > 0 && this.a == 0) { + this.world.a(this, "random.fuse", 1.0F, 0.5F); + } + + this.a += i; + if (this.a < 0) { + this.a = 0; + } + + if (this.a >= 30) { + this.a = 30; + } + } + + super.b_(); + } + + protected String f() { + return "mob.creeper"; + } + + protected String g() { + return "mob.creeperdeath"; + } + + public void f(Entity entity) { + super.f(entity); + if (entity instanceof EntitySkeleton) { + this.a(Item.GOLD_RECORD.id + this.random.nextInt(2), 1); + } + } + + protected void a(Entity entity, float f) { + int i = this.K(); + + if ((i > 0 || f >= 3.0F) && (i <= 0 || f >= 7.0F)) { + this.a(-1); + --this.a; + if (this.a < 0) { + this.a = 0; + } + } else { + if (this.a == 0) { + this.world.a(this, "random.fuse", 1.0F, 0.5F); + } + + this.a(1); + ++this.a; + if (this.a >= 30) { + // Craftbukkit start + CraftServer server = ((WorldServer) this.world).getServer(); + org.bukkit.event.Event.Type eventType = ExplosionPrimedEvent.Type.EXPLOSION_PRIMED; + ExplosionPrimedEvent event = new ExplosionPrimedEvent(eventType, CraftEntity.getEntity(server, this), 3.0F, false); + server.getPluginManager().callEvent(event); + if(!event.isCancelled()) { + this.world.a(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); + this.q(); + } else { + this.a = 0; + } + // Craftbukkit end + } + + this.e = true; + } + } + + protected int h() { + return Item.SULPHUR.id; + } + + private int K() { + return this.datawatcher.a(16); + } + + private void a(int i) { + this.datawatcher.b(16, Byte.valueOf((byte) i)); + } +} diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 029a0a9539..cb83052131 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -4,9 +4,12 @@ import java.util.List; // CraftBukkit start import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ExplosionPrimedEvent; // CraftBukkit end public class EntityFireball extends Entity { @@ -148,8 +151,16 @@ public class EntityFireball extends Entity { } // CraftBukkit end - this.world.a((Entity) null, this.locX, this.locY, this.locZ, 1.0F, true); - this.q(); + // Craftbukkit start + CraftServer server = ((WorldServer) this.world).getServer(); + org.bukkit.event.Event.Type eventType = ExplosionPrimedEvent.Type.EXPLOSION_PRIMED; + ExplosionPrimedEvent event = new ExplosionPrimedEvent(eventType, CraftEntity.getEntity(server, this), 1.0F, false); + server.getPluginManager().callEvent(event); + if(!event.isCancelled()) { + this.world.a((Entity) null, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); + this.q(); + } + // Craftbukkit end } this.locX += this.motX; diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java new file mode 100644 index 0000000000..aa0ddca999 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java @@ -0,0 +1,88 @@ +package net.minecraft.server; + +//CraftBukkit start +import org.bukkit.Server; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.event.entity.ExplosionPrimedEvent; +// CraftBukkit end + +public class EntityTNTPrimed extends Entity { + + public int a; + + public EntityTNTPrimed(World world) { + super(world); + this.a = 0; + this.i = true; + this.a(0.98F, 0.98F); + this.height = this.width / 2.0F; + } + + public EntityTNTPrimed(World world, double d0, double d1, double d2) { + this(world); + this.a(d0, d1, d2); + float f = (float) (Math.random() * 3.1415927410125732D * 2.0D); + + this.motX = (double) (-MathHelper.a(f * 3.1415927F / 180.0F) * 0.02F); + this.motY = 0.20000000298023224D; + this.motZ = (double) (-MathHelper.b(f * 3.1415927F / 180.0F) * 0.02F); + this.M = false; + this.a = 80; + this.lastX = d0; + this.lastY = d1; + this.lastZ = d2; + } + + protected void a() {} + + public boolean c_() { + return !this.dead; + } + + public void b_() { + this.lastX = this.locX; + this.lastY = this.locY; + this.lastZ = this.locZ; + this.motY -= 0.03999999910593033D; + this.c(this.motX, this.motY, this.motZ); + this.motX *= 0.9800000190734863D; + this.motY *= 0.9800000190734863D; + this.motZ *= 0.9800000190734863D; + if (this.onGround) { + this.motX *= 0.699999988079071D; + this.motZ *= 0.699999988079071D; + this.motY *= -0.5D; + } + + if (this.a-- <= 0) { + // Craftbukkit start + // Need to reverse the order of the explosion and the entity death so we have a location for the event. + this.d(); + this.q(); + // Craftbukkit end + } else { + this.world.a("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); + } + } + + private void d() { + // Craftbukkit start + CraftServer server = ((WorldServer) this.world).getServer(); + org.bukkit.event.Event.Type eventType = ExplosionPrimedEvent.Type.EXPLOSION_PRIMED; + ExplosionPrimedEvent event = new ExplosionPrimedEvent(eventType, CraftEntity.getEntity(server, this), 4.0F, false); + server.getPluginManager().callEvent(event); + if(!event.isCancelled()) { + this.world.a((Entity) null, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); + } + // Craftbukkit end + } + + protected void a(NBTTagCompound nbttagcompound) { + nbttagcompound.a("Fuse", (byte) this.a); + } + + protected void b(NBTTagCompound nbttagcompound) { + this.a = nbttagcompound.b("Fuse"); + } +}