summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityEnderCrystal.patch
blob: 3a95eb74a4d090f4a2435ad70ad93662564719ef (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
53
--- ../work/decompile-8eb82bde//net/minecraft/server/EntityEnderCrystal.java	2014-12-05 23:41:59.577572184 +0000
+++ src/main/java/net/minecraft/server/EntityEnderCrystal.java	2014-12-05 23:41:54.069572306 +0000
@@ -1,5 +1,10 @@
 package net.minecraft.server;
 
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
 public class EntityEnderCrystal extends Entity {
 
     public int a;
@@ -32,7 +37,11 @@
         int k = MathHelper.floor(this.locZ);
 
         if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(new BlockPosition(i, j, k)).getBlock() != Blocks.FIRE) {
-            this.world.setTypeUpdate(new BlockPosition(i, j, k), Blocks.FIRE.getBlockData());
+            // CraftBukkit start
+            if (!CraftEventFactory.callBlockIgniteEvent(this.world, i, j, k, this).isCancelled()) {
+                this.world.setTypeUpdate(new BlockPosition(i, j, k), Blocks.FIRE.getBlockData());
+            }
+            // CraftBukkit end
         }
 
     }
@@ -50,11 +59,25 @@
             return false;
         } else {
             if (!this.dead && !this.world.isStatic) {
+                // CraftBukkit start - All non-living entities need this
+                if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+                    return false;
+                }
+                // CraftBukkit end
+
                 this.b = 0;
                 if (this.b <= 0) {
                     this.die();
                     if (!this.world.isStatic) {
-                        this.world.explode((Entity) null, this.locX, this.locY, this.locZ, 6.0F, true);
+                        // CraftBukkit start
+                        ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false);
+                        this.world.getServer().getPluginManager().callEvent(event);
+                        if (event.isCancelled()) {
+                            this.dead = false;
+                            return false;
+                        }
+                        this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), true);
+                        // CraftBukkit end
                     }
                 }
             }