Skip to content

Commit

Permalink
Improve variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadiboo committed Jan 20, 2024
1 parent 0b0c1cc commit e4803dd
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/main/java/io/github/cadiboo/nocubes/util/ModUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,30 +109,33 @@ public static FluidState getExtendedFluidState(Level world, BlockPos pos) {
var chunkZ = z >> 4;
var chunk = world.getChunk(chunkX, chunkZ);

var fluid = chunk.getFluidState(x, y, z);
if (!fluid.isEmpty() || !NoCubes.smoothableHandler.isSmoothable(chunk.getBlockState(pos)))
return fluid;
var blockState = chunk.getBlockState(pos);
var fluidState = blockState.getFluidState();
// If the fluid is non-empty we don't have to look for a fluid
// If the state isn't smoothable we don't want to extend fluid into it
if (!fluidState.isEmpty() || !NoCubes.smoothableHandler.isSmoothable(blockState))
return fluidState;

// Check up
fluid = chunk.getFluidState(x, y + 1, z);
if (fluid.isSource())
return fluid;
fluidState = chunk.getFluidState(x, y + 1, z);
if (fluidState.isSource())
return fluidState;

// Check around
for (var extendZ = z - extendRange; extendZ <= z + extendRange; ++extendZ) {
for (var extendX = x - extendRange; extendX <= x + extendRange; ++extendX) {
if (extendZ == z && extendX == x)
continue; // We already checked ourself above
continue; // We already checked ourselves above

if (chunkX != extendZ >> 4 || chunkZ != extendX >> 4) {
chunkZ = extendZ >> 4;
chunkX = extendX >> 4;
chunk = world.getChunk(chunkX, chunkZ);
}

fluid = chunk.getFluidState(extendX, y, extendZ);
if (fluid.isSource())
return fluid;
fluidState = chunk.getFluidState(extendX, y, extendZ);
if (fluidState.isSource())
return fluidState;
}
}
return Fluids.EMPTY.defaultFluidState();
Expand Down

0 comments on commit e4803dd

Please sign in to comment.