Add entity knockback events
- EntityKnockbackEvent - EntityPushedByEntityAttackEvent - EntityKnockbackByEntityEvent Co-authored-by: aerulion <aerulion@gmail.com> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
This commit is contained in:
@@ -22,3 +22,12 @@
|
||||
flag = worldserver.destroyBlock(blockposition, true, this) || flag;
|
||||
}
|
||||
}
|
||||
@@ -281,7 +289,7 @@
|
||||
double d1 = entity.getZ() - this.getZ();
|
||||
double d2 = Math.max(d0 * d0 + d1 * d1, 0.001D);
|
||||
|
||||
- entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D);
|
||||
+ entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D, this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
--- a/net/minecraft/world/entity/monster/creaking/Creaking.java
|
||||
+++ b/net/minecraft/world/entity/monster/creaking/Creaking.java
|
||||
@@ -206,7 +206,7 @@
|
||||
@@ -198,15 +198,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void push(double deltaX, double deltaY, double deltaZ) {
|
||||
+ public void push(double deltaX, double deltaY, double deltaZ, @Nullable Entity pushingEntity) { // Paper - add push source entity param
|
||||
if (this.canMove()) {
|
||||
- super.push(deltaX, deltaY, deltaZ);
|
||||
+ super.push(deltaX, deltaY, deltaZ, pushingEntity); // Paper - add push source entity param
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Brain<Creaking> getBrain() {
|
||||
@@ -27,6 +37,18 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -502,9 +502,9 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void knockback(double strength, double x, double z) {
|
||||
+ public void knockback(double strength, double x, double z, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause) { // Paper - knockback events
|
||||
if (this.canMove()) {
|
||||
- super.knockback(strength, x, z);
|
||||
+ super.knockback(strength, x, z, attacker, cause); // Paper - knockback events
|
||||
}
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/monster/hoglin/HoglinBase.java
|
||||
+++ b/net/minecraft/world/entity/monster/hoglin/HoglinBase.java
|
||||
@@ -45,7 +45,7 @@
|
||||
double j = f * (double)(attacker.level().random.nextFloat() * 0.5F + 0.2F);
|
||||
Vec3 vec3 = new Vec3(g, 0.0, h).normalize().scale(j).yRot(i);
|
||||
double k = f * (double)attacker.level().random.nextFloat() * 0.5;
|
||||
- target.push(vec3.x, k, vec3.z);
|
||||
+ target.push(vec3.x, k, vec3.z, attacker); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
||||
target.hurtMarked = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user