restore the invariant that draining is the inverse of filling

This commit is contained in:
drwoops 2024-02-19 10:37:56 +01:00
parent 2201d87da7
commit 757f4e2699

View file

@ -38,11 +38,11 @@ public abstract class FluidManipulationBehaviour extends BlockEntityBehaviour {
public static record BlockPosEntry(BlockPos pos, int distance) { public static record BlockPosEntry(BlockPos pos, int distance) {
}; };
public static class ChunkNotLoadedException extends Exception { public static class ChunkNotLoadedException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
BoundingBox affectedArea; BoundingBox affectedArea;
BlockPos rootPos; BlockPos rootPos;
boolean infinite; boolean infinite;
@ -148,7 +148,7 @@ public abstract class FluidManipulationBehaviour extends BlockEntityBehaviour {
BiConsumer<BlockPos, Integer> add, boolean searchDownward) throws ChunkNotLoadedException { BiConsumer<BlockPos, Integer> add, boolean searchDownward) throws ChunkNotLoadedException {
Level world = getWorld(); Level world = getWorld();
int maxBlocks = maxBlocks(); int maxBlocks = maxBlocks();
int maxRange = canDrainInfinitely(fluid) ? maxRange() : maxRange() / 2; int maxRange = maxRange();
int maxRangeSq = maxRange * maxRange; int maxRangeSq = maxRange * maxRange;
int i; int i;
@ -162,7 +162,7 @@ public abstract class FluidManipulationBehaviour extends BlockEntityBehaviour {
if (!world.isLoaded(currentPos)) if (!world.isLoaded(currentPos))
throw new ChunkNotLoadedException(); throw new ChunkNotLoadedException();
FluidState fluidState = world.getFluidState(currentPos); FluidState fluidState = world.getFluidState(currentPos);
if (fluidState.isEmpty()) if (fluidState.isEmpty())
continue; continue;
@ -205,7 +205,7 @@ public abstract class FluidManipulationBehaviour extends BlockEntityBehaviour {
protected void playEffect(Level world, BlockPos pos, Fluid fluid, boolean fillSound) { protected void playEffect(Level world, BlockPos pos, Fluid fluid, boolean fillSound) {
if (fluid == null) if (fluid == null)
return; return;
BlockPos splooshPos = pos == null ? blockEntity.getBlockPos() : pos; BlockPos splooshPos = pos == null ? blockEntity.getBlockPos() : pos;
SoundEvent soundevent = fillSound ? fluid.getAttributes() SoundEvent soundevent = fillSound ? fluid.getAttributes()