Skip to content

Commit bfac70f

Browse files
committed
Only apply extra knockback when it is not zero
1 parent efc231e commit bfac70f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

patches/server/0030-Configure-Entity-Knockback.patch

+8-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ index 6162631e863dd15c7fdb70dbde2f85d273c7020b..e75322367764805443f9a9f5639d804b
5656
return;
5757
}
5858
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
59-
index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..7a48140d6f16ab56550f70a6d5aef53c2f71401b 100644
59+
index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..ddf9acf79356d6fff5caa436f67641512fb16f59 100644
6060
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
6161
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
6262
@@ -183,6 +183,7 @@ public abstract class Player extends LivingEntity {
@@ -76,10 +76,12 @@ index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..7a48140d6f16ab56550f70a6d5aef53c
7676
sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
7777
++i;
7878
flag1 = true;
79-
@@ -1324,10 +1325,24 @@ public abstract class Player extends LivingEntity {
79+
@@ -1324,10 +1325,26 @@ public abstract class Player extends LivingEntity {
8080

8181
if (flag5) {
8282
if (i > 0) {
83+
- if (target instanceof LivingEntity) {
84+
- ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit
8385
+ // Sakura start - configure extra sprinting knockback
8486
+ float extraKnockback = (float) i * 0.5F;
8587
+ long millis = System.currentTimeMillis();
@@ -93,8 +95,9 @@ index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..7a48140d6f16ab56550f70a6d5aef53c
9395
+ // -0.5 is to negate the vanilla sprinting knockback
9496
+ extraKnockback += -0.5F + (float) knockbackToApply;
9597
+ }
96-
if (target instanceof LivingEntity) {
97-
- ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit
98+
+ if (extraKnockback == 0.0) {
99+
+ // required
100+
+ } else if (target instanceof LivingEntity) {
98101
+ ((LivingEntity) target).knockback((double) (extraKnockback), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit
99102
} else {
100103
- target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
@@ -103,7 +106,7 @@ index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..7a48140d6f16ab56550f70a6d5aef53c
103106
}
104107

105108
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
106-
@@ -1349,7 +1364,7 @@ public abstract class Player extends LivingEntity {
109+
@@ -1349,7 +1366,7 @@ public abstract class Player extends LivingEntity {
107110
if (entityliving != this && entityliving != target && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
108111
// CraftBukkit start - Only apply knockback if the damage hits
109112
if (entityliving.hurt(this.damageSources().playerAttack(this).sweep().critical(flag2), f4)) { // Paper - add critical damage API

patches/server/0066-Disable-player-poses-shrinking-collision-box.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Subject: [PATCH] Disable player poses shrinking collision box
55

66

77
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
8-
index 8b5d3c429dc2676d7db33faac691a9c8f7b68f5d..2315976d480f2a8eef3e222df4f1550453dda7d4 100644
8+
index d09dfbccfb504fc5340089048541cc002d46c15f..8493566fec47ecef3fd7423b993d9e6e378df7e5 100644
99
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
1010
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
11-
@@ -2247,7 +2247,13 @@ public abstract class Player extends LivingEntity {
11+
@@ -2249,7 +2249,13 @@ public abstract class Player extends LivingEntity {
1212

1313
@Override
1414
public EntityDimensions getDimensions(Pose pose) {

0 commit comments

Comments
 (0)