PaperMC/patches/server/0187-EndermanAttackPlayerEvent.patch

29 lines
1.5 KiB
Diff
Raw Normal View History

2021-06-12 21:30:37 +02:00
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
2024-12-03 19:05:31 +01:00
index ba45d14724c29d227800e76c6a906e60ab6844d6..e9b28c7fea402cb15cfeefe6cd02e3056e54796d 100644
2021-06-12 21:30:37 +02:00
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
2024-12-03 19:05:31 +01:00
@@ -233,6 +233,14 @@ public class EnderMan extends Monster implements NeutralMob {
2021-06-12 21:30:37 +02:00
}
2023-09-22 00:01:00 +02:00
2024-10-23 00:02:50 +02:00
boolean isBeingStaredBy(Player player) {
2024-12-03 19:05:31 +01:00
+ // Paper start - EndermanAttackPlayerEvent
+ final boolean shouldAttack = isBeingStaredBy0(player);
+ final 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());
2021-06-12 21:30:37 +02:00
+ event.setCancelled(!shouldAttack);
+ return event.callEvent();
+ }
2024-10-23 00:02:50 +02:00
+ private boolean isBeingStaredBy0(Player player) {
2024-12-03 19:05:31 +01:00
+ // Paper end - EndermanAttackPlayerEvent
return !LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player) ? false : this.isLookingAtMe(player, 0.025D, true, false, new double[]{this.getEyeY()});
2024-10-23 00:02:50 +02:00
}
2023-09-22 00:01:00 +02:00