Skip to content

Commit

Permalink
Optimise simple cases for FlowingFluid#canPassThroughWall
Browse files Browse the repository at this point in the history
If both blockstates have cached collision shapes
and either one of them full occludes block or both of them
are empty, we do not need to run the further cache logic and
can return immediately.
  • Loading branch information
Spottedleaf committed Sep 16, 2023
1 parent 7299255 commit 016b3e5
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3695,6 +3695,28 @@ index d4477b0dda6a1ef7bd8323c0d11b636bd071d18e..f0de72afad4bb571153436399386a6a8
}

public PalettedContainer<BlockState> getStates() {
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
index 5502ad143fd2575f1346334b5b4fe7846628f54e..1bbe534bb3058fe804fcaa5fce62c64b48a4dd19 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -240,6 +240,17 @@ public abstract class FlowingFluid extends Fluid {
}

private boolean canPassThroughWall(Direction face, BlockGetter world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState) {
+ // Paper start - optimise collisions
+ if (state.emptyCollisionShape() & fromState.emptyCollisionShape()) {
+ // don't even try to cache simple cases
+ return true;
+ }
+
+ if (state.occludesFullBlock() | fromState.occludesFullBlock()) {
+ // don't even try to cache simple cases
+ return false;
+ }
+ // Paper end - optimise collisions
Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap;

if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) {
diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java
index ffc76354ead6937daf366c3d87bcb51d3e4c47f5..e3dbf3066337a482460238f8a94d854cf88adfa2 100644
--- a/src/main/java/net/minecraft/world/phys/AABB.java
Expand Down

0 comments on commit 016b3e5

Please sign in to comment.