Yatopia/patches/server/0041-PlayerAttackEntityEvent.patch
Ivan Pekov 4da7b3aefc
Updated Upstream and Sidestream(s) (Tuinity/EMC/Origami/Purpur/AirplaneLite)
Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Tuinity Changes:
3e77330 Updated Upstream (Paper)

EMC Changes:
e45a78e4 Update the API as well - setTargetRange to Double where null is default FOLLOW_RANGE
9fc6891d Default target range to the follow range
a1e2e2a3 Fix an issue with players in vehicles in vehicles desyncing
b6e2f202 Add a Dead vehicle reason to VehicleExitEvent
72b0da43 Use the correct entity local variable
ad32d0d6 Fix bug with entity passengers not executing entity tasks
194aaafb Updated Paper
cb3a7bb7 Always convert Lore/Name of an item to ensure consistency
6c63538d Revert "Updated Paper"
8837d5a9 Limit fortress spawns to the nether
005cdda9 Updated Paper
1476d693 Fix Lore comparisons to use legacy format
588f30f9 Quick fix the rcon log issue for now
475e626a Fix World Meta loading
3ad5f8a7 Remove RCON Thread Logs
7f3c4a25 Fix dismounting from vehicle when teleporting cross dimension
595bd307 Prevent NPE for PathfinderGoalMeleeAttack
0a64d9e9 Fix EntityDismountEvent reason
c25ef322 Updated Paper

Origami Changes:
36c0e05 Fix wrong circular dependency error if plugin depends on own provides
655fa5f Add option to disable legacy plugin support

Purpur Changes:
79d304f Updated Upstream (Paper)
bef678f [ci-skip] Simpler method of merging metadata files
3b18ff8 Updated Upstream (Paper)
25c7772 Apply the AppendingTransformer for `META-INF/services/java.sql.Driver`
faf0db9 Bump config version to 10
3d1926e More base attribute stuff
43d6dab Updated Upstream (Paper)
2fd92fe [ci-skip] Setup repo for api publishing
26b0736 Updated Upstream (Paper)
e704540 [ci-skip] Fix the remaining javadoc warnings
a541703 [ci-skip] Fix import mc-dev task
64f5f9d Fix dependency relocations
d7f1884 [ci-skip] Skip compiling tests as well as running them when using the `-Pfast` flag
3e08321 [ci-skip] Fix javadoc warnings (missing @param and @return)
1bfe697 [ci-skip] Remove paper's unsafe util
63b647c [ci-skip] Make it easier to fork Purpur using our scripts
c453170 Fix relocations
7e331c2 Fix #118 Phantom fire time not working
844337c Fix lag from villager lobotomize check
2ec0dba Updated Upstream (Paper)
69c6484 Build using Toothpick scripts (#122)

AirplaneLite Changes:
ff087b7 Changes from Purpur
7263c2f Fix maven subproject URL
819c731 Switch to Purpur's Toothpick
2020-12-22 16:01:31 +02:00

60 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Tue, 22 Sep 2020 12:52:34 +0300
Subject: [PATCH] PlayerAttackEntityEvent
Added per request
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index fea2e70a92bfd9798a4a8e256069dc20889e1259..dddc6aff8c11f9f4f295c864465ef9a128d0362e 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -1049,11 +1049,47 @@ public abstract class EntityHuman extends EntityLiving {
flag2 = flag2 && !world.paperConfig.disablePlayerCrits; // Paper
flag2 = flag2 && !this.isSprinting();
+ /* // Yatopia start - PlayerAttackEntityEvent
if (flag2) {
f *= 1.5F;
}
f += f1;
+ */
+ net.yatopia.api.event.PlayerAttackEntityEvent playerAttackEntityEvent =
+ new net.yatopia.api.event.PlayerAttackEntityEvent(
+ getBukkitEntity(),
+ entity.getBukkitEntity(),
+ org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(getItemInMainHand()),
+ flag2, f + f1
+ );
+ float totalDamage = f + f1;
+ org.bukkit.Bukkit.getPluginManager().callEvent(playerAttackEntityEvent);
+ if (playerAttackEntityEvent.isCancelled()) {
+ return;
+ }
+ flag2 = playerAttackEntityEvent.isCritical() && !world.paperConfig.disablePlayerCrits;
+ if (playerAttackEntityEvent.getDamage() == totalDamage) {
+ if (flag2) {
+ f *= 1.5F;
+ }
+ f += f1;
+ } else {
+ if (playerAttackEntityEvent.getDamage() < 0) {
+ return;
+ }
+ float damage = playerAttackEntityEvent.getDamage() - f1;
+ if (damage < 0) {
+ return;
+ }
+ if (flag2) {
+ damage *= 1.5F;
+ }
+ damage += f1;
+ f = damage;
+ }
+ // Yatopia end
+
boolean flag3 = false;
double d0 = (double) (this.A - this.z);