Skip to content

Regions

Regions is a tiny utility class of axis-aligned box fills, the rectangular-room geometry every prefab-built arena would otherwise hand-roll as a triple-nested for loop over BlockPos. The caller always picks the BlockState, so the engine stays game-agnostic about which blocks a mod uses.

  • You’re building or re-skinning rectangular arena rooms programmatically.
  • You want a solid floor, a hollow shell, just the four walls, or a colour-reveal swap of one block for another.
  • You want /fill-equivalent block-update behaviour (lighting + client sync) without writing the loop yourself.
package me.zlex.conduit.world;
public final class Regions {
public static int fill(ServerLevel level, BlockPos a, BlockPos b, BlockState state);
public static int fillHollow(ServerLevel level, BlockPos a, BlockPos b, BlockState wall);
public static int fillWalls(ServerLevel level, BlockPos a, BlockPos b, BlockState wall);
public static int replace(ServerLevel level, BlockPos a, BlockPos b, Block from, BlockState to);
}

Every method returns the number of blocks written (for replace, the number actually replaced).

MethodWhat it writes
fillThe solid box between the two corners.
fillHollowOnly the outer shell (all six faces) leaving the interior untouched (a hollow room).
fillWallsOnly the four vertical walls (not floor or ceiling).
replaceWithin the box, swaps every block matching from for to, the common “recolour” reveal. Note from is a Block, to is a BlockState.

All methods accept the two opposite corners in any order (they are normalised internally) and treat the bounds as inclusive on every axis. A min/max that differ by 0 on an axis fills exactly one block on that axis.

Writes use flag 3 (UPDATE_CLIENTS | UPDATE_NEIGHBORS) (the same flag the vanilla /fill command uses) so lighting and client sync behave the way players expect.

import me.zlex.conduit.world.Regions;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.Blocks;
public final class Arena {
public void buildRoom(ServerLevel level, BlockPos lo, BlockPos hi) {
// Hollow shell of stone, then carve out a glass floor.
Regions.fillHollow(level, lo, hi, Blocks.STONE.defaultBlockState());
BlockPos floorHi = new BlockPos(hi.getX(), lo.getY(), hi.getZ());
Regions.fill(level, lo, floorHi, Blocks.GLASS.defaultBlockState());
}
public int revealRed(ServerLevel level, BlockPos lo, BlockPos hi) {
// Swap every white concrete in the box for red, a colour reveal.
return Regions.replace(level, lo, hi,
Blocks.WHITE_CONCRETE, Blocks.RED_CONCRETE.defaultBlockState());
}
}