Screen placement
ScreenPlacement is a tiny record — a world-space center and an outward unit normal — that says where a screen sits and which way it faces. Placements is the helper class for computing common placements: in front of a player at distance D, snapped to the horizontal plane so the panel is always upright.
When to use it
Section titled “When to use it”- You want a panel to appear in front of the player at a fixed distance, regardless of head pitch.
- You’re computing your own wall-mount and just need the record shape.
- You’re rendering a sibling label or display next to an existing screen and want to reuse its placement.
package me.zlex.conduit.screen.placement;
public record ScreenPlacement(Vec3 center, Vec3 normal) {}
public final class Placements { /** Placement {@code distance} blocks in front of the player's eyes. * Normal snapped to horizontal — the panel is always upright. */ public static ScreenPlacement inFrontOf(ServerPlayer player, float distance);}ServerScreenManager.show and showWithId both accept a ScreenPlacement directly so you don’t have to unpack centre + normal yourself.
Example
Section titled “Example”import me.zlex.conduit.screen.ScreenContent;import me.zlex.conduit.screen.ServerScreenManager;import me.zlex.conduit.screen.placement.Placements;import me.zlex.conduit.screen.placement.ScreenPlacement;import net.minecraft.server.level.ServerPlayer;
public final class HubMenu {
public static void openMenu(ServerPlayer p) { ScreenPlacement place = Placements.inFrontOf(p, 2.0f); ScreenContent menu = HubMenuScreen.build(); ServerScreenManager.show(p, place, 3.5f, 2.5f, menu); }}inFrontOfsnaps the look direction to the horizontal plane — looking straight up or down still produces an upright panel.- The normal points toward the viewer, not away — this is the convention every renderer in the engine uses.
- If you want a wall-anchored panel that stays put when the player moves, compute the placement once and store it (e.g. on
BaseLobby.screenPlacement).