Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3// CraftBukkit start
4
5import org.bukkit.craftbukkit.CraftServer;
6import org.bukkit.craftbukkit.entity.CraftEntity;
7import org.bukkit.entity.Explosive;
8import org.bukkit.event.entity.ExplosionPrimeEvent;
9// CraftBukkit end
10
11public class EntityTNTPrimed extends Entity {
12
13 public int fuseTicks;
14 public float yield = 4; // CraftBukkit
15 public boolean isIncendiary = false; // CraftBukkit
16
17 public EntityTNTPrimed(World world) {
18 super(world);
19 this.fuseTicks = 0;
20 this.aI = true;
21 this.b(0.98F, 0.98F);
22 this.height = this.width / 2.0F;
23 }
24
25 public EntityTNTPrimed(World world, double d0, double d1, double d2) {
26 this(world);
27 this.setPosition(d0, d1, d2);
28 float f = (float) (Math.random() * 3.1415927410125732D * 2.0D);
29
30 this.motX = (double) (-MathHelper.sin(f * 3.1415927F / 180.0F) * 0.02F);
31 this.motY = 0.20000000298023224D;
32 this.motZ = (double) (-MathHelper.cos(f * 3.1415927F / 180.0F) * 0.02F);
33 this.fuseTicks = 80;
34 this.lastX = d0;
35 this.lastY = d1;
36 this.lastZ = d2;
37 }
38
39 protected void b() {
40 }
41
42 protected boolean n() {
43 return false;
44 }
45
46 public boolean l_() {
47 return !this.dead;
48 }
49
50 public void m_() {
51 this.lastX = this.locX;
52 this.lastY = this.locY;
53 this.lastZ = this.locZ;
54 this.motY -= 0.03999999910593033D;
55 this.move(this.motX, this.motY, this.motZ);
56 this.motX *= 0.9800000190734863D;
57 this.motY *= 0.9800000190734863D;
58 this.motZ *= 0.9800000190734863D;
59 if (this.onGround) {
60 this.motX *= 0.699999988079071D;
61 this.motZ *= 0.699999988079071D;
62 this.motY *= -0.5D;
63 }
64
65 if (this.fuseTicks-- <= 0) {
66 if (!this.world.isStatic) {
67 // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event.
68 this.explode();
69 this.die();
70 // CraftBukkit end
71 } else {
72 this.die();
73 }
74 } else {
75 this.world.a("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
76 }
77 }
78
79 private void explode() {
80 // CraftBukkit start
81 // float f = 4.0F;
82
83 CraftServer server = this.world.getServer();
84
85 ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) CraftEntity.getEntity(server, this));
86 server.getPluginManager().callEvent(event);
87
88 if (!event.isCancelled()) {
89 // give 'this' instead of (Entity) null so we know what causes the damage
90 this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
91 }
92 // CraftBukkit end
93 }
94
95 protected void b(NBTTagCompound nbttagcompound) {
96 nbttagcompound.a("Fuse", (byte) this.fuseTicks);
97 }
98
99 protected void a(NBTTagCompound nbttagcompound) {
100 this.fuseTicks = nbttagcompound.c("Fuse");
101 }
102}