summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityTNTPrimed.patch
blob: 9167c320e3afffd335f2259acde7d6b1b83decc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--- /home/matt/mc-dev-private//net/minecraft/server/EntityTNTPrimed.java	2015-02-26 22:40:22.707608138 +0000
+++ src/main/java/net/minecraft/server/EntityTNTPrimed.java	2015-02-26 22:40:22.711608138 +0000
@@ -1,9 +1,13 @@
 package net.minecraft.server;
 
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+
 public class EntityTNTPrimed extends Entity {
 
     public int fuseTicks;
     private EntityLiving source;
+    public float yield = 4; // CraftBukkit - add field
+    public boolean isIncendiary = false; // CraftBukkit - add field
 
     public EntityTNTPrimed(World world) {
         super(world);
@@ -52,10 +56,13 @@
         }
 
         if (this.fuseTicks-- <= 0) {
-            this.die();
+            // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
+            // this.die();
             if (!this.world.isClientSide) {
                 this.explode();
             }
+            this.die();
+            // CraftBukkit end
         } else {
             this.W();
             this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]);
@@ -64,9 +71,18 @@
     }
 
     private void explode() {
-        float f = 4.0F;
+        // CraftBukkit start
+        // float f = 4.0F;
+        
+        org.bukkit.craftbukkit.CraftServer server = this.world.getServer();
 
-        this.world.explode(this, this.locX, this.locY + (double) (this.length / 16.0F), this.locZ, f, true);
+        ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.CraftEntity.getEntity(server, this));
+        server.getPluginManager().callEvent(event);
+
+        if (!event.isCancelled()) {
+            this.world.createExplosion(this, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, event.getRadius(), event.getFire(), true);
+        }
+        // CraftBukkit end
     }
 
     protected void b(NBTTagCompound nbttagcompound) {