aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0193-EndermanAttackPlayerEvent.patch
blob: ccd3efb275b1a9b9ffff6f470c43e07e3c41af1c (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
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 3e50f3dc5b9a45ee8f368f91fbd67b599d4435fb..4d659fc8355542e6b9cadc6e1e86002e136702d2 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -231,7 +231,15 @@ public class EnderMan extends Monster implements NeutralMob {
         this.readPersistentAngerSaveData(this.level(), nbt);
     }
 
-    boolean isLookingAtMe(Player player) {
+    // Paper start - EndermanAttackPlayerEvent
+    private boolean isLookingAtMe(Player player) {
+        boolean shouldAttack = isLookingAtMe_check(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 isLookingAtMe_check(Player player) {
+        // Paper end - EndermanAttackPlayerEvent
         ItemStack itemstack = (ItemStack) player.getInventory().armor.get(3);
 
         if (itemstack.is(Blocks.CARVED_PUMPKIN.asItem())) {