From a7dbe8a38e70ae565e5c66b20d4e2c0b4451aa3b Mon Sep 17 00:00:00 2001 From: Allink <44676012+allinkdev@users.noreply.github.com> Date: Mon, 28 Nov 2022 03:48:26 +0000 Subject: [PATCH] Prevent velocity freeze (#68) --- .../server/0042-Prevent-velocity-freeze.patch | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 patches/server/0042-Prevent-velocity-freeze.patch diff --git a/patches/server/0042-Prevent-velocity-freeze.patch b/patches/server/0042-Prevent-velocity-freeze.patch new file mode 100644 index 0000000..8520f98 --- /dev/null +++ b/patches/server/0042-Prevent-velocity-freeze.patch @@ -0,0 +1,86 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Allink +Date: Sun, 27 Nov 2022 04:56:24 +0000 +Subject: [PATCH] Prevent velocity freeze + + +diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +index fa4e930388baa2ee0a752873b2ec1a67cc020de6..8ba2433de1e079e2227b97a5a7b5f06a6f34984f 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +@@ -41,9 +41,13 @@ public abstract class AbstractHurtingProjectile extends Projectile { + double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); + + if (d6 != 0.0D) { +- this.xPower = d3 / d6 * 0.1D; +- this.yPower = d4 / d6 * 0.1D; +- this.zPower = d5 / d6 * 0.1D; ++ // Scissors start - Prevent projectile velocity freeze ++ //this.xPower = d3 / d6 * 0.1D; ++ //this.yPower = d4 / d6 * 0.1D; ++ //this.zPower = d5 / d6 * 0.1D; ++ // Scissors end ++ ++ setPower(d3 / d6 * .1d, d4 / d6 * .1d, d5 / d6 * .1d); + } + + } +@@ -150,6 +154,25 @@ public abstract class AbstractHurtingProjectile extends Projectile { + nbt.put("power", this.newDoubleList(new double[]{this.xPower, this.yPower, this.zPower})); + } + ++ // Scissors start - Prevent projectile velocity freeze ++ public void setPower(double xPower, double yPower, double zPower) ++ { ++ if (Double.isInfinite(xPower) || Double.isInfinite(yPower) || Double.isInfinite(zPower)) ++ { ++ return; ++ } ++ ++ if (Double.isNaN(xPower) || Double.isNaN(yPower) || Double.isNaN(zPower)) ++ { ++ return; ++ } ++ ++ this.xPower = xPower; ++ this.yPower = yPower; ++ this.zPower = zPower; ++ } ++ // Scissors end ++ + @Override + public void readAdditionalSaveData(CompoundTag nbt) { + super.readAdditionalSaveData(nbt); +@@ -157,9 +180,13 @@ public abstract class AbstractHurtingProjectile extends Projectile { + ListTag nbttaglist = nbt.getList("power", 6); + + if (nbttaglist.size() == 3) { +- this.xPower = nbttaglist.getDouble(0); +- this.yPower = nbttaglist.getDouble(1); +- this.zPower = nbttaglist.getDouble(2); ++ // Scissors start - Prevent projectile velocity freeze ++ //this.xPower = nbttaglist.getDouble(0); ++ //this.yPower = nbttaglist.getDouble(1); ++ //this.zPower = nbttaglist.getDouble(2); ++ // Scissors end ++ ++ setPower(nbttaglist.getDouble(0), nbttaglist.getDouble(1), nbttaglist.getDouble(2)); + } + } + +@@ -193,9 +220,12 @@ public abstract class AbstractHurtingProjectile extends Projectile { + Vec3 vec3d = entity.getLookAngle(); + + this.setDeltaMovement(vec3d); +- this.xPower = vec3d.x * 0.1D; +- this.yPower = vec3d.y * 0.1D; +- this.zPower = vec3d.z * 0.1D; ++ // Scissors start - Prevent projectile velocity freeze ++ //this.xPower = vec3d.x * 0.1D; ++ //this.yPower = vec3d.y * 0.1D; ++ //this.zPower = vec3d.z * 0.1D; ++ setPower(vec3d.x * 0.1D, vec3d.y * 0.1D, vec3d.z * 0.1D); ++ // Scissors end + this.setOwner(entity); + } +