summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntitySmallFireball.patch
blob: 46d5a04165b9cda2ed27abf262983857f4e95d10 (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
54
55
56
57
58
--- a/net/minecraft/server/EntitySmallFireball.java
+++ b/net/minecraft/server/EntitySmallFireball.java
@@ -1,5 +1,7 @@
 package net.minecraft.server;
 
+import org.bukkit.event.entity.EntityCombustByEntityEvent; // CraftBukkit
+
 public class EntitySmallFireball extends EntityFireball {
 
     public EntitySmallFireball(World world) {
@@ -8,6 +10,11 @@
 
     public EntitySmallFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
         super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world, 0.3125F, 0.3125F);
+        // CraftBukkit start
+        if (this.shooter != null && this.shooter instanceof EntityInsentient) {
+            isIncendiary = this.world.getGameRules().getBoolean("mobGriefing");
+        }
+        // CraftBukkit end
     }
 
     public EntitySmallFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) {
@@ -20,7 +27,16 @@
 
             if (movingobjectposition.entity != null) {
                 if (!movingobjectposition.entity.isFireProof()) {
-                    movingobjectposition.entity.setOnFire(5);
+                    // CraftBukkit start - Entity damage by entity event + combust event
+                    if (isIncendiary) {
+                        EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity.getBukkitEntity(), 5);
+                        movingobjectposition.entity.world.getServer().getPluginManager().callEvent(event);
+
+                        if (!event.isCancelled()) {
+                            movingobjectposition.entity.setOnFire(event.getDuration());
+                        }
+                    }
+                    // CraftBukkit end
                     flag = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5.0F);
                     if (flag) {
                         this.a(this.shooter, movingobjectposition.entity);
@@ -32,11 +48,15 @@
                     flag = this.world.getGameRules().getBoolean("mobGriefing");
                 }
 
-                if (flag) {
+                // CraftBukkit start
+                if (isIncendiary) {
                     BlockPosition blockposition = movingobjectposition.a().shift(movingobjectposition.direction);
 
                     if (this.world.isEmpty(blockposition)) {
-                        this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+                        if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) {
+                            this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+                        }
+                        // CraftBukkit end
                     }
                 }
             }