PaperMC/src/main/java/net/minecraft/server/EntityTNTPrimed.java

92 lines
2.8 KiB
Java
Raw Normal View History

2011-02-04 04:03:11 +01:00
package net.minecraft.server;
2011-02-23 13:56:36 +01:00
// CraftBukkit start
2011-02-04 04:03:11 +01:00
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftEntity;
2011-03-18 22:57:22 +01:00
import org.bukkit.event.entity.ExplosionPrimeEvent;
2011-02-04 04:03:11 +01:00
// CraftBukkit end
public class EntityTNTPrimed extends Entity {
public int a;
public EntityTNTPrimed(World world) {
super(world);
this.a = 0;
2011-02-23 03:37:56 +01:00
this.aC = true;
2011-02-04 04:03:11 +01:00
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);
2011-02-23 03:37:56 +01:00
this.bg = false;
2011-02-04 04:03:11 +01:00
this.a = 80;
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
}
protected void a() {}
2011-02-23 03:37:56 +01:00
public boolean d_() {
2011-02-04 04:03:11 +01:00
return !this.dead;
}
2011-02-23 03:37:56 +01:00
public void f_() {
2011-02-04 04:03:11 +01:00
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) {
2011-02-23 13:56:36 +01:00
// CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event.
2011-02-23 03:37:56 +01:00
this.h();
this.C();
2011-02-23 13:56:36 +01:00
// CraftBukkit end
2011-02-04 04:03:11 +01:00
} else {
this.world.a("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
}
}
2011-02-23 03:37:56 +01:00
private void h() {
float f = 4.0F;
2011-02-23 13:56:36 +01:00
// CraftBukkit start
2011-02-04 04:03:11 +01:00
CraftServer server = ((WorldServer) this.world).getServer();
2011-03-18 22:57:22 +01:00
org.bukkit.event.Event.Type eventType = ExplosionPrimeEvent.Type.EXPLOSION_PRIME;
2011-02-23 13:56:36 +01:00
2011-03-18 22:57:22 +01:00
ExplosionPrimeEvent event = new ExplosionPrimeEvent(eventType, CraftEntity.getEntity(server, this), f, false);
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()) {
// give 'this' instead of (Entity) null so we know what causes the damage
this.world.a(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
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
}
protected void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("Fuse", (byte) this.a);
}
protected void b(NBTTagCompound nbttagcompound) {
2011-02-23 03:37:56 +01:00
this.a = nbttagcompound.c("Fuse");
2011-02-04 04:03:11 +01:00
}
}