summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntitySkeletonAbstract.patch
blob: db96e176e25867e2e657f1afdd6c4ce5cf3eea20 (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
--- a/net/minecraft/server/EntitySkeletonAbstract.java
+++ b/net/minecraft/server/EntitySkeletonAbstract.java
@@ -2,12 +2,13 @@
 
 import java.util.Calendar;
 import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit
 
 public abstract class EntitySkeletonAbstract extends EntityMonster implements IRangedEntity {
 
     private static final DataWatcherObject<Boolean> a = DataWatcher.a(EntitySkeletonAbstract.class, DataWatcherRegistry.h);
     private final PathfinderGoalBowShoot b = new PathfinderGoalBowShoot(this, 1.0D, 20, 15.0F);
-    private final PathfinderGoalMeleeAttack c = new PathfinderGoalMeleeAttack(this, 1.2D, flag) {
+    private final PathfinderGoalMeleeAttack c = new PathfinderGoalMeleeAttack(this, 1.2D, false) { // CraftBukkit - decompile error
         public void d() {
             super.d();
             EntitySkeletonAbstract.this.a(false);
@@ -80,7 +81,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
                 }
             }
         }
@@ -99,7 +107,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;
@@ -109,6 +117,7 @@
                 entityhuman.b((Statistic) AchievementList.v);
             }
         }
+        super.die(damagesource); // CraftBukkit - moved from above
 
     }
 
@@ -166,8 +175,19 @@
         double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
 
         entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4));
+        // CraftBukkit start
+        org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), entityarrow, 0.8F);
+        if (event.isCancelled()) {
+            event.getProjectile().remove();
+            return;
+        }
+
+        if (event.getProjectile() == entityarrow.getBukkitEntity()) {
+            world.addEntity(entityarrow);
+        }
+        // CraftBukkit end
         this.a(SoundEffects.fV, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
-        this.world.addEntity(entityarrow);
+        // this.world.addEntity(entityarrow); // CraftBukkit - moved up
     }
 
     protected EntityArrow a(float f) {