mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
a207d14a0e
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
46 lines
2.4 KiB
Diff
46 lines
2.4 KiB
Diff
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 1981c08af85b16d45531ffae4fe790bb31edec04..d190b58bea310f4006ea3deaf0d42c502d441284 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
|
@@ -221,20 +221,28 @@ public class EnderMan extends Monster implements NeutralMob {
|
|
this.readPersistentAngerSaveData((ServerLevel) this.level, tag);
|
|
}
|
|
|
|
+ // Paper start - OBFHELPER - ok not really, but verify this on updates
|
|
private boolean isLookingAtMe(Player player) {
|
|
- ItemStack itemstack = (ItemStack) player.inventory.armor.get(3);
|
|
+ boolean shouldAttack = g_real(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 g_real(Player entityhuman) {
|
|
+ // Paper end
|
|
+ ItemStack itemstack = (ItemStack) entityhuman.inventory.armor.get(3);
|
|
|
|
if (itemstack.getItem() == Blocks.CARVED_PUMPKIN.asItem()) {
|
|
return false;
|
|
} else {
|
|
- Vec3 vec3d = player.getViewVector(1.0F).normalize();
|
|
- Vec3 vec3d1 = new Vec3(this.getX() - player.getX(), this.getEyeY() - player.getEyeY(), this.getZ() - player.getZ());
|
|
+ Vec3 vec3d = entityhuman.getViewVector(1.0F).normalize();
|
|
+ Vec3 vec3d1 = new Vec3(this.getX() - entityhuman.getX(), this.getEyeY() - entityhuman.getEyeY(), this.getZ() - entityhuman.getZ());
|
|
double d0 = vec3d1.length();
|
|
|
|
vec3d1 = vec3d1.normalize();
|
|
double d1 = vec3d.dot(vec3d1);
|
|
|
|
- return d1 > 1.0D - 0.025D / d0 ? player.canSee(this) : false;
|
|
+ return d1 > 1.0D - 0.025D / d0 ? entityhuman.canSee(this) : false;
|
|
}
|
|
}
|
|
|