SPIGOT-5553, #1336: Add EntityKnockbackEvent

By: Jishuna <joshl5324@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2024-01-27 14:53:41 +11:00
parent 67ab2cd516
commit 7b15562116
5 changed files with 179 additions and 81 deletions

View File

@@ -303,7 +303,7 @@
this.leashInfoTag = null;
}
}
@@ -1501,7 +1619,14 @@
@@ -1501,14 +1619,21 @@
int i = EnchantmentManager.getFireAspect(this);
if (i > 0) {
@@ -319,6 +319,14 @@
}
boolean flag = entity.hurt(this.damageSources().mobAttack(this), f);
if (flag) {
if (f1 > 0.0F && entity instanceof EntityLiving) {
- ((EntityLiving) entity).knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)));
+ ((EntityLiving) entity).knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot())) * 0.017453292F, this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
}
@@ -1576,6 +1701,7 @@
@Override
protected void removeAfterChangingDimensions() {