summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntitySkeleton.patch
blob: 63a27c52a044933b0b82d840e5274b4f1270f5db (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
--- a/net/minecraft/server/EntitySkeleton.java
+++ b/net/minecraft/server/EntitySkeleton.java
@@ -2,13 +2,14 @@
 
 import java.util.Calendar;
 import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit
 
 public class EntitySkeleton extends EntityMonster implements IRangedEntity {
 
     private static final DataWatcherObject<Integer> a = DataWatcher.a(EntitySkeleton.class, DataWatcherRegistry.b);
     private static final DataWatcherObject<Boolean> b = DataWatcher.a(EntitySkeleton.class, DataWatcherRegistry.h);
     private final PathfinderGoalBowShoot c = new PathfinderGoalBowShoot(this, 1.0D, 20, 15.0F);
-    private final PathfinderGoalMeleeAttack bw = new PathfinderGoalMeleeAttack(this, 1.2D, flag) {
+    private final PathfinderGoalMeleeAttack bw = new PathfinderGoalMeleeAttack(this, 1.2D, false) { // CraftBukkit decompile error flag -> false
         public void d() {
             super.d();
             EntitySkeleton.this.a(false);
@@ -103,7 +104,14 @@
                 }
 
                 if (flag) {
-                    this.setOnFire(8);
+                    // CraftBukkit start
+                    EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
+                    this.world.getServer().getPluginManager().callEvent(event);
+
+                    if (!event.isCancelled()) {
+                        this.setOnFire(event.getDuration());
+                    }
+                    // CraftBukkit end
                 }
             }
         }
@@ -126,7 +134,7 @@
     }
 
     public void die(DamageSource damagesource) {
-        super.die(damagesource);
+        // super.die(damagesource); // CraftBukkit
         if (damagesource.i() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) {
             EntityHuman entityhuman = (EntityHuman) damagesource.getEntity();
             double d0 = entityhuman.locX - this.locX;
@@ -139,6 +147,7 @@
             ((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
             this.a(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
         }
+        super.die(damagesource); // CraftBukkit - moved from above
 
     }
 
@@ -222,11 +231,30 @@
         }
 
         if (EnchantmentManager.a(Enchantments.ARROW_FIRE, (EntityLiving) this) > 0 || this.getSkeletonType() == 1) {
-            entitytippedarrow.setOnFire(100);
+            // CraftBukkit start - call EntityCombustEvent
+            EntityCombustEvent event = new EntityCombustEvent(entitytippedarrow.getBukkitEntity(), 100);
+            this.world.getServer().getPluginManager().callEvent(event);
+
+            if (!event.isCancelled()) {
+                entitytippedarrow.setOnFire(event.getDuration());
+            }
+            // CraftBukkit end
+        }
+
+        // CraftBukkit start
+        org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), entitytippedarrow, 0.8F);
+        if (event.isCancelled()) {
+            event.getProjectile().remove();
+            return;
+        }
+
+        if (event.getProjectile() == entitytippedarrow.getBukkitEntity()) {
+            world.addEntity(entitytippedarrow);
         }
+        // CraftBukkit end
 
         this.a(SoundEffects.fo, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
-        this.world.addEntity(entitytippedarrow);
+        // this.world.addEntity(entitytippedarrow); // CraftBukkit - moved up
     }
 
     public int getSkeletonType() {