summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityTNTPrimed.java
diff options
context:
space:
mode:
authorculturespy <culturespy@gmail.com>2011-02-03 22:03:11 -0500
committerEvilSeph <evilseph@unaligned.org>2011-02-12 02:57:58 -0500
commite2899b9dd7e211e0e2da7d997e982d9fa5b1754f (patch)
treed9bf1080a855c1969aab2d93cf9d2b466c1236a6 /src/main/java/net/minecraft/server/EntityTNTPrimed.java
parent348e6c75c73376a32b2bf0cf81a549a3a93cace5 (diff)
downloadcraftbukkit-e2899b9dd7e211e0e2da7d997e982d9fa5b1754f.tar
craftbukkit-e2899b9dd7e211e0e2da7d997e982d9fa5b1754f.tar.gz
craftbukkit-e2899b9dd7e211e0e2da7d997e982d9fa5b1754f.tar.lz
craftbukkit-e2899b9dd7e211e0e2da7d997e982d9fa5b1754f.tar.xz
craftbukkit-e2899b9dd7e211e0e2da7d997e982d9fa5b1754f.zip
Added EXPLOSION_PRIMED event.
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityTNTPrimed.java')
-rw-r--r--src/main/java/net/minecraft/server/EntityTNTPrimed.java88
1 files changed, 88 insertions, 0 deletions
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 00000000..aa0ddca9
--- /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");
+ }
+}