94 lines
6.1 KiB
Diff
94 lines
6.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Fri, 26 Jun 2020 14:28:49 -0700
|
|
Subject: [PATCH] fixup! Implement EntityKnockbackByEntityEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
index 3fa9e7b52b24629c96436fdd46d4e8c28c35f00e..2cada09ced1660526e9c112c2c8d92bbf9d6ea98 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -1094,9 +1094,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
if (flag5) {
|
|
if (i > 0) {
|
|
if (entity instanceof EntityLiving) {
|
|
- ((EntityLiving) entity).knockingBackEntity = this; // Paper
|
|
- ((EntityLiving) entity).a((float) i * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)));
|
|
- ((EntityLiving) entity).knockingBackEntity = null; // Paper
|
|
+ ((EntityLiving) entity).doKnockback((float) i * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)), this); // Paper
|
|
} else {
|
|
entity.h((double) (-MathHelper.sin(this.yaw * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.yaw * 0.017453292F) * (float) i * 0.5F));
|
|
}
|
|
@@ -1120,9 +1118,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) {
|
|
// CraftBukkit start - Only apply knockback if the damage hits
|
|
if (entityliving.damageEntity(DamageSource.playerAttack(this).sweep(), f4)) {
|
|
- ((EntityLiving) entity).knockingBackEntity = this; // Paper
|
|
- entityliving.a(0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)));
|
|
- ((EntityLiving) entity).knockingBackEntity = null; // Paper
|
|
+ entityliving.doKnockback(0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)), this);
|
|
}
|
|
// CraftBukkit end
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
index 61323f9b15350b1d227b2f3de67c40846ba7c2f9..677f88a44a92509d932f9bb7b1258a6ccecde256 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
@@ -1493,9 +1493,7 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
|
|
if (flag) {
|
|
if (f1 > 0.0F && entity instanceof EntityLiving) {
|
|
- ((EntityLiving) entity).knockingBackEntity = this; // Paper
|
|
- ((EntityLiving) entity).a(f1 * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)));
|
|
- ((EntityLiving) entity).knockingBackEntity = null; // Paper
|
|
+ ((EntityLiving) entity).doKnockback(f1 * 0.5F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)), this);
|
|
this.setMot(this.getMot().d(0.6D, 1.0D, 0.6D));
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index 14606a12c472e0e58f76023a53a4129536ac5cc4..7a2140e4b901027997b2884275b35b43fe2175bc 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -1240,9 +1240,7 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
this.aw = (float) (MathHelper.d(d1, d0) * 57.2957763671875D - (double) this.yaw);
|
|
- this.knockingBackEntity = entity1 instanceof EntityLiving ? ((EntityLiving) entity1) : null; // Paper
|
|
- this.a(0.4F, d0, d1);
|
|
- this.knockingBackEntity = null; // Paper
|
|
+ this.doKnockback(0.4F, d0, d1, entity1); // Paper
|
|
} else {
|
|
this.aw = (float) ((int) (Math.random() * 2.0D) * 180);
|
|
}
|
|
@@ -1294,9 +1292,7 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
protected void f(EntityLiving entityliving) {
|
|
- ((EntityLiving) entityliving).knockingBackEntity = this; // Paper
|
|
- entityliving.a(0.5F, entityliving.locX() - this.locX(), entityliving.locZ() - this.locZ());
|
|
- ((EntityLiving) entityliving).knockingBackEntity = null; // Paper
|
|
+ entityliving.doKnockback(0.5F, entityliving.locX() - this.locX(), entityliving.locZ() - this.locZ(), this);
|
|
}
|
|
|
|
private boolean f(DamageSource damagesource) {
|
|
@@ -1559,6 +1555,11 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
public void a(float f, double d0, double d1) {
|
|
+ // Paper start - add knockbacking entity parameter
|
|
+ this.doKnockback(f, d0, d1, null);
|
|
+ }
|
|
+ public void doKnockback(float f, double d0, double d1, Entity knockingBackEntity) {
|
|
+ // Paper end - add knockbacking entity parameter
|
|
f = (float) ((double) f * (1.0D - this.b(GenericAttributes.KNOCKBACK_RESISTANCE)));
|
|
if (f > 0.0F) {
|
|
this.impulse = true;
|
|
@@ -1578,7 +1579,6 @@ public abstract class EntityLiving extends Entity {
|
|
// Paper end
|
|
}
|
|
}
|
|
- EntityLiving knockingBackEntity; // Paper
|
|
|
|
@Nullable
|
|
protected SoundEffect getSoundHurt(DamageSource damagesource) {
|