add Escape Reason Drown for EndermanEscapeEvent

to detect rain specifically from every other armor ignoring hit
This commit is contained in:
Aikar 2018-05-31 18:16:26 -04:00
parent 7fea752ffc
commit 727f932d05
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
2 changed files with 13 additions and 9 deletions

View File

@ -1,4 +1,4 @@
From 56e8465d9383fd6771c00c0ac017b30844a6fb9b Mon Sep 17 00:00:00 2001
From 16691e65657636278f4e967df7130d011194d5b9 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 30 Apr 2018 13:14:30 -0400
Subject: [PATCH] EndermanEscapeEvent
@ -9,10 +9,10 @@ You may cancel this, enabling ranged attacks to damage the enderman for example.
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EndermanEscapeEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EndermanEscapeEvent.java
new file mode 100644
index 00000000..b8de1037
index 00000000..0d15a8ab
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EndermanEscapeEvent.java
@@ -0,0 +1,78 @@
@@ -0,0 +1,82 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.Enderman;
@ -88,9 +88,13 @@ index 00000000..b8de1037
+ /**
+ * The enderman has teleported away due to the player staring at it during combat
+ */
+ STARE
+ STARE,
+ /**
+ * Specific case for CRITICAL_HIT where the enderman is taking rain damage
+ */
+ DROWN
+ }
+}
--
2.17.0
2.17.1

View File

@ -1,4 +1,4 @@
From 501fbfa880f4f5ff495424d4360d7b601f03e7cc Mon Sep 17 00:00:00 2001
From adb90c86f6eba145015f676b640e17a119fdf6ca Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 30 Apr 2018 13:15:55 -0400
Subject: [PATCH] EndermanEscapeEvent
@ -8,7 +8,7 @@ Fires an event anytime an enderman intends to teleport away from the player
You may cancel this, enabling ranged attacks to damage the enderman for example.
diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java
index 2f59e7071..bf32e386c 100644
index 2f59e7071..e8ea231dc 100644
--- a/src/main/java/net/minecraft/server/EntityEnderman.java
+++ b/src/main/java/net/minecraft/server/EntityEnderman.java
@@ -1,5 +1,6 @@
@ -54,7 +54,7 @@ index 2f59e7071..bf32e386c 100644
boolean flag = super.damageEntity(damagesource, f);
- if (damagesource.ignoresArmor() && this.random.nextInt(10) != 0) {
+ if (damagesource.ignoresArmor() && this.random.nextInt(10) != 0 && tryEscape(EndermanEscapeEvent.Reason.CRITICAL_HIT)) { // Paper
+ if (damagesource.ignoresArmor() && this.random.nextInt(10) != 0 && tryEscape(damagesource == DamageSource.DROWN ? EndermanEscapeEvent.Reason.DROWN : EndermanEscapeEvent.Reason.CRITICAL_HIT)) { // Paper
this.dm();
}
@ -77,5 +77,5 @@ index 2f59e7071..bf32e386c 100644
}
--
2.17.0
2.17.1