aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0188-EndermanAttackPlayerEvent.patch
blob: 7ec73bf7df7742314ad3b537da2577a93b33acfe (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 1 May 2018 20:18:54 -0400
Subject: [PATCH] EndermanAttackPlayerEvent

Allow control over whether or not an enderman aggros a player.

This allows you to override/extend the pumpkin/stare logic.

diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index d7145b3a19402a03d0af02822ffcb0ef07eaa663..5f1bbb4302013c2c1788db6b64eafba2a11a373a 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -234,6 +234,14 @@ public class EnderMan extends Monster implements NeutralMob {
     }
 
     boolean isBeingStaredBy(Player player) {
+    // Paper start - EndermanAttackPlayerEvent
+        boolean shouldAttack = isBeingStaredBy0(player);
+        com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent event = new com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent((org.bukkit.entity.Enderman) getBukkitEntity(), (org.bukkit.entity.Player) player.getBukkitEntity());
+        event.setCancelled(!shouldAttack);
+        return event.callEvent();
+    }
+    private boolean isBeingStaredBy0(Player player) {
+    // Paper end - EndermanAttackPlayerEvent
         return this.isLookingAtMe(player, 0.025D, true, false, LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM, new DoubleSupplier[]{this::getEyeY});
     }