Skip to content

Commit

Permalink
Change getSeenFraction to return float
Browse files Browse the repository at this point in the history
Vanilla uses float here, so it may change behaviorly slightly
by using more precision.
  • Loading branch information
Spottedleaf committed Sep 13, 2023
1 parent 259f2da commit 7299255
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions patches/server/0029-Actually-optimise-explosions.patch
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The results indicate that this logic is 5 times faster than Vanilla
and 2.3 times faster than Lithium.

diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index e8c4815960ab144298d4352f393b9670e7004e62..744b9e4666aade8d84f84807900d4ee31afef7b6 100644
index e8c4815960ab144298d4352f393b9670e7004e62..53f708a58a2b86fb81602b028a357990a632b49b 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -96,6 +96,271 @@ public class Explosion {
Expand Down Expand Up @@ -257,7 +257,7 @@ index e8c4815960ab144298d4352f393b9670e7004e62..744b9e4666aade8d84f84807900d4ee3
+ }
+ }
+
+ private double getSeenFraction(final Vec3 source, final Entity target,
+ private float getSeenFraction(final Vec3 source, final Entity target,
+ final ExplosionBlockCache[] blockCache,
+ final BlockPos.MutableBlockPos blockPos) {
+ final AABB boundingBox = target.getBoundingBox();
Expand All @@ -270,7 +270,7 @@ index e8c4815960ab144298d4352f393b9670e7004e62..744b9e4666aade8d84f84807900d4ee3
+ final double incZ = 1.0 / (diffZ * 2.0 + 1.0);
+
+ if (incX < 0.0 || incY < 0.0 || incZ < 0.0) {
+ return 0.0;
+ return 0.0f;
+ }
+
+ final double offX = (1.0 - Math.floor(1.0 / incX) * incX) * 0.5 + boundingBox.minX;
Expand Down Expand Up @@ -302,7 +302,7 @@ index e8c4815960ab144298d4352f393b9670e7004e62..744b9e4666aade8d84f84807900d4ee3
+ }
+ }
+
+ return (double)missedRays / (double)totalRays;
+ return (float)missedRays / (float)totalRays;
+ }
+ // Paper end - optimise collisions
+
Expand Down

0 comments on commit 7299255

Please sign in to comment.