2020-09-22 12:15:06 +02:00
|
|
|
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
|
2021-02-02 16:17:46 +01:00
|
|
|
index 7ee038e24cf696b7a32c5c67d4b0dd46c1e60118..6b09b5d10ba824d589ee998c19d347074ad81d17 100644
|
2020-09-22 12:15:06 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
2021-02-02 16:17:46 +01:00
|
|
|
@@ -1069,12 +1069,50 @@ public abstract class EntityHuman extends EntityLiving {
|
2020-09-22 12:15:06 +02:00
|
|
|
|
|
|
|
flag2 = flag2 && !world.paperConfig.disablePlayerCrits; // Paper
|
|
|
|
flag2 = flag2 && !this.isSprinting();
|
2021-01-21 11:58:52 +01:00
|
|
|
- if (flag2) {
|
|
|
|
- this.isCritical = true; // Purpur
|
|
|
|
- f *= 1.5F;
|
2020-09-22 14:21:04 +02:00
|
|
|
+ /* // Yatopia start - PlayerAttackEntityEvent
|
2021-01-21 11:58:52 +01:00
|
|
|
+ if (flag2) {
|
|
|
|
+ this.isCritical = true; // Purpur
|
|
|
|
+ f *= 1.5F;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ f += f1;
|
2020-09-22 14:21:04 +02:00
|
|
|
+ */
|
2020-09-22 12:15:06 +02:00
|
|
|
+ net.yatopia.api.event.PlayerAttackEntityEvent playerAttackEntityEvent =
|
|
|
|
+ new net.yatopia.api.event.PlayerAttackEntityEvent(
|
2020-09-22 14:21:04 +02:00
|
|
|
+ getBukkitEntity(),
|
2020-09-22 12:15:06 +02:00
|
|
|
+ entity.getBukkitEntity(),
|
2020-09-22 14:21:04 +02:00
|
|
|
+ org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(getItemInMainHand()),
|
2020-09-22 12:15:06 +02:00
|
|
|
+ flag2, f + f1
|
|
|
|
+ );
|
|
|
|
+ float totalDamage = f + f1;
|
|
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(playerAttackEntityEvent);
|
|
|
|
+ if (playerAttackEntityEvent.isCancelled()) {
|
|
|
|
+ return;
|
2021-01-21 11:58:52 +01:00
|
|
|
}
|
2020-09-22 14:21:04 +02:00
|
|
|
+ flag2 = playerAttackEntityEvent.isCritical() && !world.paperConfig.disablePlayerCrits;
|
2020-09-22 12:15:06 +02:00
|
|
|
+ if (playerAttackEntityEvent.getDamage() == totalDamage) {
|
2020-09-22 14:21:04 +02:00
|
|
|
+ if (flag2) {
|
2021-01-21 11:58:52 +01:00
|
|
|
+ this.isCritical = true; // Purpur
|
2020-09-22 12:15:06 +02:00
|
|
|
+ f *= 1.5F;
|
|
|
|
+ }
|
|
|
|
+ f += f1;
|
|
|
|
+ } else {
|
|
|
|
+ if (playerAttackEntityEvent.getDamage() < 0) {
|
2021-01-21 11:58:52 +01:00
|
|
|
+ return;
|
2020-09-22 12:15:06 +02:00
|
|
|
+ }
|
|
|
|
+ float damage = playerAttackEntityEvent.getDamage() - f1;
|
|
|
|
+ if (damage < 0) {
|
2021-01-21 11:58:52 +01:00
|
|
|
+ return;
|
2020-09-22 12:15:06 +02:00
|
|
|
+ }
|
2020-09-22 14:21:04 +02:00
|
|
|
+ if (flag2) {
|
2021-01-21 11:58:52 +01:00
|
|
|
+ this.isCritical = true; // Purpur
|
2020-09-22 12:15:06 +02:00
|
|
|
+ damage *= 1.5F;
|
|
|
|
+ }
|
|
|
|
+ damage += f1;
|
|
|
|
+ f = damage;
|
|
|
|
+ }
|
|
|
|
+ // Yatopia end
|
2021-01-21 11:58:52 +01:00
|
|
|
|
|
|
|
- f += f1;
|
2020-09-22 14:21:04 +02:00
|
|
|
boolean flag3 = false;
|
|
|
|
double d0 = (double) (this.A - this.z);
|
2020-09-22 12:15:06 +02:00
|
|
|
|