Yatopia/patches/server/0015-EMC-EntityKnockbackEvent.patch
2020-03-21 17:29:35 +01:00

62 lines
3.4 KiB
Diff

From 360d20b06b9e2b1b8e68275a3ba054e1de3e7a65 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 16 Mar 2014 20:44:46 -0400
Subject: [PATCH] EMC EntityKnockbackEvent
Control knockback power of entity attacks
---
.../java/net/minecraft/server/EnchantmentManager.java | 9 +++++++--
src/main/java/net/minecraft/server/EntityHuman.java | 2 +-
src/main/java/net/minecraft/server/EntityInsentient.java | 2 +-
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/main/java/net/minecraft/server/EnchantmentManager.java b/src/main/java/net/minecraft/server/EnchantmentManager.java
index d96c03a1..9fc637f9 100644
--- a/src/main/java/net/minecraft/server/EnchantmentManager.java
+++ b/src/main/java/net/minecraft/server/EnchantmentManager.java
@@ -186,8 +186,13 @@ public class EnchantmentManager {
}
}
- public static int b(EntityLiving entityliving) {
- return a(Enchantments.KNOCKBACK, entityliving);
+ // EMC start - rename and add target
+ public static int getKnockbackEnchantmentLevel(EntityLiving entityliving, EntityLiving target) { // EMC - OBF HELPER
+ int level = a(Enchantments.KNOCKBACK, entityliving);
+ com.empireminecraft.customevents.EntityKnockbackEvent event = new com.empireminecraft.customevents.EntityKnockbackEvent((org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(), target != null ? (org.bukkit.entity.LivingEntity) target.getBukkitEntity() : null, level);
+ event.callEvent();
+ return event.getLevel();
+ // EMC end
}
public static int getFireAspectEnchantmentLevel(EntityLiving entityliving) {
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 584166f2..9346fbf0 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -1062,7 +1062,7 @@ public abstract class EntityHuman extends EntityLiving {
boolean flag = f2 > 0.9F;
boolean flag1 = false;
byte b0 = 0;
- int i = b0 + EnchantmentManager.b((EntityLiving) this);
+ int i = b0 + EnchantmentManager.getKnockbackEnchantmentLevel(this, entity instanceof EntityLiving ? (EntityLiving) entity : null); // EMC
if (this.isSprinting() && flag) {
sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.getSoundCategory(), 1.0F, 1.0F); // Paper - send while respecting visibility
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 27ef4760..0592e095 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -1315,7 +1315,7 @@ public abstract class EntityInsentient extends EntityLiving {
if (entity instanceof EntityLiving) {
f += EnchantmentManager.a(this.getItemInMainHand(), ((EntityLiving) entity).getMonsterType());
- f1 += (float) EnchantmentManager.b((EntityLiving) this);
+ f1 += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity); // EMC
}
int i = EnchantmentManager.getFireAspectEnchantmentLevel(this);
--
2.25.1.windows.1