Skip to content

How the sponge works

This page describes the vanilla sponge as it behaves in Minecraft 26.1.2, and marks where Configurable Sponge changes it. Understanding it explains why the two settings behave the way they do.

When a sponge looks for water

A dry sponge checks for water in two situations:

  • when it is placed
  • when a neighbouring block changes, for example when water flows against it or a block next to it is broken

If the check removes at least one block of water, the sponge becomes a wet sponge and plays its absorb sound. If there was nothing to remove, it stays dry. A wet sponge does not search at all, and this mod does not change it.

The sponge runs a breadth-first search outward from its own block:

  1. The sponge's block is the starting point. It uses up one of the maxCount slots.
  2. The search visits the six blocks touching the current block, one step further from the sponge each time. Blocks nearest the sponge are handled first, so the search grows outward in rings.
  3. Each visited block is checked. If it holds water, it is emptied and counts towards maxCount, and the search continues from it. If it does not, it is skipped, and the search does not continue through it.
  4. The search stops when it runs out of reachable water, when a block is further than maxDepth steps from the sponge, or when maxCount blocks have been used.

Because a skipped block is a dead end, the search only follows water that is connected to the sponge. Water behind a wall or across a gap of air is out of reach.

SettingWhat it limitsVanilla valueSet by this mod
maxDepthHow many steps from the sponge a block can be6sponge.maxDepth
maxCountHow many blocks the search can use, including the sponge65sponge.maxCount

Since the sponge uses one slot, vanilla's 65 means 64 blocks of water. See Configuration.

What counts as water

The block must contain water. Lava and other fluids are never touched. Within that:

BlockWhat the sponge does
Water (source or flowing)Removes it
Waterlogged blocks, such as a waterlogged slab or stairsEmpties the water and keeps the block
Kelp and seagrassBreaks them and drops their items

Each of these counts as one block towards maxCount.

What this mod changes

The mod replaces the two numbers in the sponge's search, and nothing else:

java
@ModifyConstant(method = "removeWaterBreadthFirstSearch", constant = @Constant(intValue = 6))
private int modifyMaxDepth(int original) { return ModCommonConfig.maxDepth(); }

@ModifyConstant(method = "removeWaterBreadthFirstSearch", constant = @Constant(intValue = 65))
private int modifyMaxCount(int original) { return ModCommonConfig.maxCount(); }

The values are read every time a sponge searches, which is why edits to the config file apply straight away.

It also means a sponge is not the only thing that changes with the config. Anything that extends the vanilla sponge block and uses its search takes on the new numbers too. Blocks that run their own search are unaffected.

Next

Released under the MIT License.