9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-22 08:19:26 +00:00

Only apply extra knockback when it is not zero

This commit is contained in:
Samsuik
2024-05-28 22:38:45 +01:00
parent efc231e60f
commit bfac70f0d1
2 changed files with 10 additions and 7 deletions

View File

@@ -56,7 +56,7 @@ index 6162631e863dd15c7fdb70dbde2f85d273c7020b..e75322367764805443f9a9f5639d804b
return; return;
} }
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..7a48140d6f16ab56550f70a6d5aef53c2f71401b 100644 index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..ddf9acf79356d6fff5caa436f67641512fb16f59 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -183,6 +183,7 @@ public abstract class Player extends LivingEntity { @@ -183,6 +183,7 @@ public abstract class Player extends LivingEntity {
@@ -76,10 +76,12 @@ index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..7a48140d6f16ab56550f70a6d5aef53c
sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
++i; ++i;
flag1 = true; flag1 = true;
@@ -1324,10 +1325,24 @@ public abstract class Player extends LivingEntity { @@ -1324,10 +1325,26 @@ public abstract class Player extends LivingEntity {
if (flag5) { if (flag5) {
if (i > 0) { if (i > 0) {
- if (target instanceof LivingEntity) {
- ((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
+ // Sakura start - configure extra sprinting knockback + // Sakura start - configure extra sprinting knockback
+ float extraKnockback = (float) i * 0.5F; + float extraKnockback = (float) i * 0.5F;
+ long millis = System.currentTimeMillis(); + long millis = System.currentTimeMillis();
@@ -93,8 +95,9 @@ index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..7a48140d6f16ab56550f70a6d5aef53c
+ // -0.5 is to negate the vanilla sprinting knockback + // -0.5 is to negate the vanilla sprinting knockback
+ extraKnockback += -0.5F + (float) knockbackToApply; + extraKnockback += -0.5F + (float) knockbackToApply;
+ } + }
if (target instanceof LivingEntity) { + if (extraKnockback == 0.0) {
- ((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 + // required
+ } else if (target instanceof LivingEntity) {
+ ((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 + ((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
} else { } else {
- 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 - 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
} }
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
@@ -1349,7 +1364,7 @@ public abstract class Player extends LivingEntity { @@ -1349,7 +1366,7 @@ public abstract class Player extends LivingEntity {
if (entityliving != this && entityliving != target && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) { if (entityliving != this && entityliving != target && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
// CraftBukkit start - Only apply knockback if the damage hits // CraftBukkit start - Only apply knockback if the damage hits
if (entityliving.hurt(this.damageSources().playerAttack(this).sweep().critical(flag2), f4)) { // Paper - add critical damage API if (entityliving.hurt(this.damageSources().playerAttack(this).sweep().critical(flag2), f4)) { // Paper - add critical damage API

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Disable player poses shrinking collision box
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 8b5d3c429dc2676d7db33faac691a9c8f7b68f5d..2315976d480f2a8eef3e222df4f1550453dda7d4 100644 index d09dfbccfb504fc5340089048541cc002d46c15f..8493566fec47ecef3fd7423b993d9e6e378df7e5 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -2247,7 +2247,13 @@ public abstract class Player extends LivingEntity { @@ -2249,7 +2249,13 @@ public abstract class Player extends LivingEntity {
@Override @Override
public EntityDimensions getDimensions(Pose pose) { public EntityDimensions getDimensions(Pose pose) {