summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityEnderCrystal.patch
blob: e8fe828c4a939e576bb6cdb04473c96d24165d35 (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
--- a/net/minecraft/server/EntityEnderCrystal.java
+++ b/net/minecraft/server/EntityEnderCrystal.java
@@ -3,6 +3,11 @@
 import com.google.common.base.Optional;
 import javax.annotation.Nullable;
 
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
 public class EntityEnderCrystal extends Entity {
 
     private static final DataWatcherObject<Optional<BlockPosition>> b = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.k);
@@ -39,7 +44,11 @@
             BlockPosition blockposition = new BlockPosition(this);
 
             if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(blockposition).getBlock() != Blocks.FIRE) {
-                this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+                // CraftBukkit start
+                if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
+                    this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+                }
+                // CraftBukkit end
             }
         }
 
@@ -75,10 +84,23 @@
             return false;
         } else {
             if (!this.dead && !this.world.isClientSide) {
+                // CraftBukkit start - All non-living entities need this
+                if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+                    return false;
+                }
+                // CraftBukkit end
                 this.die();
                 if (!this.world.isClientSide) {
                     if (!damagesource.isExplosion()) {
-                        this.world.explode((Entity) null, this.locX, this.locY, this.locZ, 6.0F, true);
+                        // CraftBukkit start
+                        ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, true);
+                        this.world.getServer().getPluginManager().callEvent(event);
+                        if (event.isCancelled()) {
+                            this.dead = false;
+                            return false;
+                        }
+                        this.world.explode(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
+                        // CraftBukkit end
                     }
 
                     this.a(damagesource);