summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityPigZombie.patch
blob: 5420df19cec9b7a2b8cd6362a43ba56ebc6a3df2 (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
--- a/net/minecraft/server/EntityPigZombie.java
+++ b/net/minecraft/server/EntityPigZombie.java
@@ -113,16 +113,27 @@
         } else {
             Entity entity = damagesource.getEntity();
 
-            if (entity instanceof EntityHuman && !((EntityHuman) entity).u()) {
+            // CraftBukkit start
+            boolean result = super.damageEntity(damagesource, f);
+
+            if (result && entity instanceof EntityHuman && !((EntityHuman) entity).u()) {
                 this.a(entity);
             }
 
-            return super.damageEntity(damagesource, f);
+            return result;
+            // CraftBukkit end
         }
     }
 
     private void a(Entity entity) {
-        this.angerLevel = 400 + this.random.nextInt(400);
+        // CraftBukkit start
+        org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), 400 + this.random.nextInt(400));
+        this.world.getServer().getPluginManager().callEvent(event);
+        if (event.isCancelled()) {
+            return;
+        }
+        this.angerLevel = event.getNewAnger();
+        // CraftBukkit end
         this.soundDelay = this.random.nextInt(40);
         if (entity instanceof EntityLiving) {
             this.setLastDamager((EntityLiving) entity);