Prefab geometry
The geometry primitives Prefab elements use to describe shape: BlockVolumeShape chooses solid / walls-only / shell; IntVec3 is a triple of IntExpr for parametric coordinates; IntExpr parses literals, parameter refs (@xMin), and parameter + offset (@xMin + 1); OrientationUtil converts between cardinal directions and integer yaw for the yawDegrees field on screens and labels.
When to use it
Section titled “When to use it”- You’re authoring a prefab and want to know which shape variants exist.
- You’re writing tooling that emits prefab JSON and need the coordinate grammar.
- You’re rotating screens or labels by yaw and want the conversion helpers.
package me.zlex.conduit.prefab;
public enum BlockVolumeShape { CUBOID, // every block inside the AABB WALLS, // four side walls across all y SHELL; // all six faces — walls + floor + ceiling
public static final Codec<BlockVolumeShape> CODEC;}
public record IntVec3(IntExpr x, IntExpr y, IntExpr z) { public BlockPos resolve(PrefabBindings bindings); public BlockPos resolveAt(PrefabBindings bindings, BlockPos origin); public static final Codec<IntVec3> CODEC;}
public sealed interface IntExpr { int eval(PrefabBindings bindings);
record Literal(int value) implements IntExpr {} record ParamRef(String name) implements IntExpr {} record Offset(String name, int delta) implements IntExpr {}
static IntExpr parse(String text); Codec<IntExpr> CODEC; // accepts JSON number or string}
public final class OrientationUtil { public static int directionToYaw(Direction d); public static Vec3 yawToNormal(int yawDegrees); public static int snapYaw(int yawDegrees, int step); public static int normalise(int yawDegrees);}Example
Section titled “Example”Authoring side (JSON):
{ "elements": [ { "type": "block-volume", "shape": "shell", "block": "minecraft:barrier", "from": ["@xMin", "@yFloor", "@zMin"], "to": ["@xMax", "@yCeiling", "@zMax"] },
{ "type": "block-volume", "shape": "walls", "block": "minecraft:glass", "from": ["@xMin + 1", "@yFloor + 1", "@zMin + 1"], "to": ["@xMax - 1", "@yCeiling - 1", "@zMax - 1"] } ]}Consumer side (Java):
import me.zlex.conduit.prefab.OrientationUtil;import net.minecraft.core.Direction;import net.minecraft.world.phys.Vec3;
public final class WallMount {
public static Vec3 normalFromDirection(Direction face) { int yaw = OrientationUtil.directionToYaw(face); return OrientationUtil.yawToNormal(yaw); }
public static int rotateClockwise15(int currentYaw) { return OrientationUtil.snapYaw(currentYaw + 15, 15); }}IntExpris deliberately tiny — three forms only. Anything more elaborate, add a named parameter instead of growing the expression language.- Yaw convention:
0°is+Z(south),90°is+X(east). UP/DOWN map to 0 — there’s no vertical-axis rotation in the data model. BlockVolumeShape.SHELLis the “hollow cube” primitive used by/set <block>in the editor.