From b1b5d4c1e4b7c95afd5c932ca392bee66533a60c Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 10 Aug 2024 11:55:08 +0200 Subject: [PATCH] Check shooter in configurable projectile relative velocity patch --- ...figurable-projectile-relative-velocity.patch | 17 ++++++++++++----- patches/server/0677-More-Projectile-API.patch | 6 +++--- ...-look-changes-from-crashing-the-server.patch | 6 +++--- .../1042-Fix-PickupStatus-getting-reset.patch | 4 ++-- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/patches/server/0295-Configurable-projectile-relative-velocity.patch b/patches/server/0295-Configurable-projectile-relative-velocity.patch index 9406e01b81..1616b1c050 100644 --- a/patches/server/0295-Configurable-projectile-relative-velocity.patch +++ b/patches/server/0295-Configurable-projectile-relative-velocity.patch @@ -25,15 +25,22 @@ P3) Solutions for 1) and especially 2) might not be future-proof, while this server-internal fix makes this change future-proof. diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index 30eb86b52f00cfa61af4f93aca50ffc3547c95e8..7863625d49baa13ea87f2ee295b16706071fb960 100644 +index 30eb86b52f00cfa61af4f93aca50ffc3547c95e8..19452d1e591afc06675d57bbebae963517ab7217 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -183,7 +183,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -182,8 +182,14 @@ public abstract class Projectile extends Entity implements TraceableEntity { + this.shoot((double) f5, (double) f6, (double) f7, speed, divergence); Vec3 vec3d = shooter.getKnownMovement(); - -- this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, shooter.onGround() ? 0.0D : vec3d.y, vec3d.z)); -+ if (!shooter.level().paperConfig().misc.disableRelativeProjectileVelocity) this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, shooter.onGround() ? 0.0D : vec3d.y, vec3d.z)); // Paper - allow disabling relative velocity +- ++ // Paper start - allow disabling relative velocity ++ if (vec3d.lengthSqr() > 4D * 4D) { ++ vec3d = vec3d.normalize().scale(2D); ++ } ++ if (!shooter.level().paperConfig().misc.disableRelativeProjectileVelocity) { + this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, shooter.onGround() ? 0.0D : vec3d.y, vec3d.z)); ++ } ++ // Paper end - allow disabling relative velocity } // CraftBukkit start - call projectile hit event diff --git a/patches/server/0677-More-Projectile-API.patch b/patches/server/0677-More-Projectile-API.patch index 1fb8d2e9f1..3d4ddc9624 100644 --- a/patches/server/0677-More-Projectile-API.patch +++ b/patches/server/0677-More-Projectile-API.patch @@ -50,10 +50,10 @@ index 5b7734020b496ade3740d92908ad2d399bfd55e6..e70ca1b2e6fbbc1f20e65429298d01b4 public boolean calculateOpenWater(BlockPos pos) { FishingHook.OpenWaterType entityfishinghook_waterposition = FishingHook.OpenWaterType.INVALID; diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index 7863625d49baa13ea87f2ee295b16706071fb960..ff6007bbf8361db7967b6bf621b27a1d23102e77 100644 +index 19452d1e591afc06675d57bbebae963517ab7217..bc65321aee27192c40428ac6f58ccec0f0cdc2ee 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -187,7 +187,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -193,7 +193,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { } // CraftBukkit start - call projectile hit event @@ -713,7 +713,7 @@ index e374b9f40eddca13b30855d25a2030f8df98138f..4fc893378fb0568ddcffc7593d66df6b // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 4180b86620aa18a95e0793f646515779801a343e..ffc55cf79d0e7f90ba2816d7604477f018d75ecd 100644 +index 48f320333fa859796f4fff01f721fda903238197..9c85cbc65bf7e1f539f12644ed391c98118c08d2 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -841,19 +841,19 @@ public class CraftEventFactory { diff --git a/patches/server/0737-Stop-large-look-changes-from-crashing-the-server.patch b/patches/server/0737-Stop-large-look-changes-from-crashing-the-server.patch index 592bb75b03..93357dd58b 100644 --- a/patches/server/0737-Stop-large-look-changes-from-crashing-the-server.patch +++ b/patches/server/0737-Stop-large-look-changes-from-crashing-the-server.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Stop large look changes from crashing the server Co-authored-by: Jaren Knodel diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index fa9512da351ef92a8606b3e68ee060dac4c63346..e6335a55d87444d56d6f20dfc51cc4fc797de2cf 100644 +index 4a9abb2457b175c640d1e59de161fa2370053613..9c8e23f92a4cf902b060af4ce74777753e32f207 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3158,37 +3158,15 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -54,10 +54,10 @@ index fa9512da351ef92a8606b3e68ee060dac4c63346..e6335a55d87444d56d6f20dfc51cc4fc this.level().getProfiler().pop(); this.animStep += f2; diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index ff6007bbf8361db7967b6bf621b27a1d23102e77..d147f3cc1af28c384005c1c20e37bb588588c88d 100644 +index bc65321aee27192c40428ac6f58ccec0f0cdc2ee..dd53501d39113c4b0b5950bad70a5c667c0781c5 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -310,13 +310,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -316,13 +316,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { } protected static float lerpRotation(float prevRot, float newRot) { diff --git a/patches/server/1042-Fix-PickupStatus-getting-reset.patch b/patches/server/1042-Fix-PickupStatus-getting-reset.patch index 795972058b..2a772419ce 100644 --- a/patches/server/1042-Fix-PickupStatus-getting-reset.patch +++ b/patches/server/1042-Fix-PickupStatus-getting-reset.patch @@ -24,10 +24,10 @@ index ddf47dab1ab92c45e3eea09239d418a9798ed59e..9ca29b3d4bf8bca5f51f3644e12fcbec byte b0 = 0; diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index 5f7d152f41eb85f17bcded4bc8099b998e5a338b..a01c0d9ae53d1b748c5da914069bd672cb1215c7 100644 +index 4b71538d5e921af89c4b13200484d4767e4dd6f9..de64de5d1328d3e0826c9990eb7c7eca5088cb9c 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -237,7 +237,13 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -243,7 +243,13 @@ public abstract class Projectile extends Entity implements TraceableEntity { public boolean deflect(ProjectileDeflection deflection, @Nullable Entity deflector, @Nullable Entity owner, boolean fromAttack) { if (!this.level().isClientSide) { deflection.deflect(this, deflector, this.random);