2011-02-04 04:03:11 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
|
2011-02-04 04:03:11 +01:00
|
|
|
|
|
|
|
public class EntityTNTPrimed extends Entity {
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public int fuseTicks;
|
2013-03-13 23:33:27 +01:00
|
|
|
private EntityLiving source;
|
2011-06-14 20:03:29 +02:00
|
|
|
public float yield = 4; // CraftBukkit
|
|
|
|
public boolean isIncendiary = false; // CraftBukkit
|
2011-02-04 04:03:11 +01:00
|
|
|
|
|
|
|
public EntityTNTPrimed(World world) {
|
|
|
|
super(world);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.m = true;
|
|
|
|
this.a(0.98F, 0.98F);
|
2011-11-30 00:17:43 +01:00
|
|
|
this.height = this.length / 2.0F;
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public EntityTNTPrimed(World world, double d0, double d1, double d2, EntityLiving entityliving) {
|
2011-02-04 04:03:11 +01:00
|
|
|
this(world);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition(d0, d1, d2);
|
2011-02-04 04:03:11 +01:00
|
|
|
float f = (float) (Math.random() * 3.1415927410125732D * 2.0D);
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
this.motX = (double) (-((float) Math.sin((double) f)) * 0.02F);
|
2011-02-04 04:03:11 +01:00
|
|
|
this.motY = 0.20000000298023224D;
|
2012-03-01 11:49:23 +01:00
|
|
|
this.motZ = (double) (-((float) Math.cos((double) f)) * 0.02F);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.fuseTicks = 80;
|
2011-02-04 04:03:11 +01:00
|
|
|
this.lastX = d0;
|
|
|
|
this.lastY = d1;
|
|
|
|
this.lastZ = d2;
|
2013-03-13 23:33:27 +01:00
|
|
|
this.source = entityliving;
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a() {}
|
2011-02-04 04:03:11 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected boolean e_() {
|
2011-03-31 22:40:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean K() {
|
2011-02-04 04:03:11 +01:00
|
|
|
return !this.dead;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void l_() {
|
2011-02-04 04:03:11 +01:00
|
|
|
this.lastX = this.locX;
|
|
|
|
this.lastY = this.locY;
|
|
|
|
this.lastZ = this.locZ;
|
|
|
|
this.motY -= 0.03999999910593033D;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.move(this.motX, this.motY, this.motZ);
|
2011-02-04 04:03:11 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.fuseTicks-- <= 0) {
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
|
2011-05-26 14:48:22 +02:00
|
|
|
if (!this.world.isStatic) {
|
|
|
|
this.explode();
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
this.die();
|
|
|
|
// CraftBukkit end
|
2011-02-04 04:03:11 +01:00
|
|
|
} else {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.addParticle("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
private void explode() {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
2011-06-14 20:03:29 +02:00
|
|
|
// float f = 4.0F;
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
org.bukkit.craftbukkit.CraftServer server = this.world.getServer();
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.CraftEntity.getEntity(server, this));
|
2011-02-04 04:03:11 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (!event.isCancelled()) {
|
2011-03-17 18:30:14 +01:00
|
|
|
// give 'this' instead of (Entity) null so we know what causes the damage
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), true);
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected void b(NBTTagCompound nbttagcompound) {
|
2011-11-30 00:17:43 +01:00
|
|
|
nbttagcompound.setByte("Fuse", (byte) this.fuseTicks);
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected void a(NBTTagCompound nbttagcompound) {
|
2011-11-30 00:17:43 +01:00
|
|
|
this.fuseTicks = nbttagcompound.getByte("Fuse");
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
2013-03-13 23:33:27 +01:00
|
|
|
|
|
|
|
public EntityLiving getSource() {
|
|
|
|
return this.source;
|
|
|
|
}
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|