Yatopia/patches/server/0038-PlayerAttackEntityEvent.patch
Simon Gardling 021f928c4d
Updated Upstream and Sidestream(s) (Paper/Purpur/AirplaneLite/Origami) (#382)
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.

Paper Changes:
0514fc4e2 Add missing effects
8f5d9effd Add getMainThreadExecutor to BukkitScheduler
313b5020b Allow adding items to BlockDropItemEvent (#5093)
9a556d9da [CI-SKIP] [Auto] Rebuild Patches
72b2768ad Inline shift fields in EnumDirection (#5082)
ffff53fa7 added option to disable pathfinding updates on block changes (#5123)
b67081fd7 add DragonEggFormEvent (fixes #5110) (#5112)
3eefafbaf Fix javadoc build
0081ed1c4 Add javadoc step to GH Actions
01082503e Add dropLeash variable to EntityUnleashEvent (#5130)
31f9f869a [CI-SKIP] Fix YourKit links in readme, fixes #5091
8ac27aa38 [Auto] Updated Upstream (CraftBukkit)
c4d9cc831 [Auto] Updated Upstream (Bukkit/CraftBukkit)
d0477d326 [Auto] Updated Upstream (CraftBukkit)
d9f5f7018 EntityMoveEvent (#4614)

Purpur Changes:
e581a73 Updated Upstream (Paper)

AirplaneLite Changes:
10c5810 Updated Upstream (Tuinity)

Origami Changes:
45d89cc Update Paper
578ef16 Automatically disable online-mode if bungeecord is enabled
de51baa Update Paper
5986aef Import Purpur patch to not send useless entity packets
2021-02-02 10:17:46 -05:00

67 lines
3.1 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 7ee038e24cf696b7a32c5c67d4b0dd46c1e60118..6b09b5d10ba824d589ee998c19d347074ad81d17 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -1069,12 +1069,50 @@ public abstract class EntityHuman extends EntityLiving {
flag2 = flag2 && !world.paperConfig.disablePlayerCrits; // Paper
flag2 = flag2 && !this.isSprinting();
- if (flag2) {
- this.isCritical = true; // Purpur
- f *= 1.5F;
+ /* // Yatopia start - PlayerAttackEntityEvent
+ if (flag2) {
+ this.isCritical = true; // Purpur
+ 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) {
+ this.isCritical = true; // Purpur
+ f *= 1.5F;
+ }
+ f += f1;
+ } else {
+ if (playerAttackEntityEvent.getDamage() < 0) {
+ return;
+ }
+ float damage = playerAttackEntityEvent.getDamage() - f1;
+ if (damage < 0) {
+ return;
+ }
+ if (flag2) {
+ this.isCritical = true; // Purpur
+ damage *= 1.5F;
+ }
+ damage += f1;
+ f = damage;
+ }
+ // Yatopia end
- f += f1;
boolean flag3 = false;
double d0 = (double) (this.A - this.z);