diff options
author | Noah van der Aa <[email protected]> | 2021-12-20 23:46:51 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-12-20 22:46:51 +0000 |
commit | ae6fec6d13255847ade2d54aa6462addbb1ad4d0 (patch) | |
tree | 47d80db0bb562e275d9723a0dddd32f50cb7fcf1 /patches/server/0703-Improve-boat-collision-performance.patch | |
parent | 6178609e1d7e9fda3d59786b69425a3b00d73298 (diff) | |
download | Paper-ae6fec6d13255847ade2d54aa6462addbb1ad4d0.tar.gz Paper-ae6fec6d13255847ade2d54aa6462addbb1ad4d0.zip |
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#7116)
Diffstat (limited to 'patches/server/0703-Improve-boat-collision-performance.patch')
-rw-r--r-- | patches/server/0703-Improve-boat-collision-performance.patch | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/patches/server/0703-Improve-boat-collision-performance.patch b/patches/server/0703-Improve-boat-collision-performance.patch new file mode 100644 index 0000000000..9e8bbe1be1 --- /dev/null +++ b/patches/server/0703-Improve-boat-collision-performance.patch @@ -0,0 +1,70 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf <[email protected]> +Date: Mon, 2 Aug 2021 10:10:40 +0200 +Subject: [PATCH] Improve boat collision performance + + +diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java +index cc565d1f766d5a6e0fe674ee9e453dbcb890116e..5bdd1958dff2fc9321bf858e6aa4cc5ad0a5a9ca 100644 +--- a/src/main/java/net/minecraft/Util.java ++++ b/src/main/java/net/minecraft/Util.java +@@ -84,6 +84,7 @@ public class Util { + }).findFirst().orElseThrow(() -> { + return new IllegalStateException("No jar file system provider found"); + }); ++ public static final double COLLISION_EPSILON = 1.0E-7; // Paper + private static Consumer<String> thePauser = (string) -> { + }; + +diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java +index 2b0ba27fbded68270421f31037f71bb81f98d139..3f210da11885a292e999ede1f894ecf5f4930117 100644 +--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +@@ -1316,7 +1316,7 @@ public abstract class LivingEntity extends Entity { + if (!source.isProjectile()) { + Entity entity = source.getDirectEntity(); + +- if (entity instanceof LivingEntity) { ++ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper + this.blockUsingShield((LivingEntity) entity); + } + } +@@ -1425,11 +1425,12 @@ public abstract class LivingEntity extends Entity { + } + + if (entity1 != null) { +- double d0 = entity1.getX() - this.getX(); ++ final boolean far = entity1.distanceToSqr(this) > (200.0 * 200.0); // Paper ++ double d0 = far ? (Math.random() - Math.random()) : entity1.getX() - this.getX(); // Paper + + double d1; + +- for (d1 = entity1.getZ() - this.getZ(); d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) { ++ for (d1 = far ? Math.random() - Math.random() : entity1.getZ() - this.getZ(); d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) { // Paper + d0 = (Math.random() - Math.random()) * 0.01D; + } + +@@ -2099,7 +2100,7 @@ public abstract class LivingEntity extends Entity { + this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING)); + Entity entity = damagesource.getDirectEntity(); + +- if (entity instanceof LivingEntity) { ++ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper + this.blockUsingShield((LivingEntity) entity); + } + } +diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java +index c3d111204601270b57389e1f85456a9e2ada4629..b967177cb10041f96831322c311579e409050e88 100644 +--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java ++++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java +@@ -687,8 +687,8 @@ public class Boat extends Entity { + this.invFriction = 0.05F; + if (this.oldStatus == Boat.Status.IN_AIR && this.status != Boat.Status.IN_AIR && this.status != Boat.Status.ON_LAND) { + this.waterLevel = this.getY(1.0D); +- this.setPos(this.getX(), (double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D, this.getZ()); +- this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D)); ++ this.move(MoverType.SELF, new Vec3(0.0, ((double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D) - this.getY(), 0.0)); // Paper ++ this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D)); // Paper + this.lastYd = 0.0D; + this.status = Boat.Status.IN_WATER; + } else { |