Overview
The client mod (protectedareaclient) is a Fabric mod that runs
exclusively on the player's game client. It has four responsibilities:
- Receive and store area data sent by the server plugin or server mod.
- Render colored outline boxes around areas in the game world.
- Render a custom sky texture when the player is inside an area that has a skybox assigned.
- Enforce
no_entryandno_exitrules through client-side collision physics. - Display a multi-page debug HUD when enabled by a server admin.
The mod is entirely passive on servers that do not run the plugin or server mod. It listens for
packets on the protectedarea:main channel and does nothing if no packets arrive.
Area Outlines
When a server admin runs /area view <player> true, the client mod
renders a wireframe box around every area in the player's current world.
The color of each box is set with /area color.
How it works
The renderer hooks into Fabric's WorldRenderEvents.AFTER_TRANSLUCENT_LAYER event.
On each frame, it iterates all stored areas, filters to those in the player's current dimension,
and draws 12 lines (the edges of a box) using camera-relative coordinates for precision.
The color is parsed from the hex code stored in each area and passed directly to the line renderer. Areas without a color set are not rendered.
Setup
/area color spawn #4488FF Spawn Zone
/area view Marquinho true
/area view Marquinho false # Disable when no longer needed
Custom Skybox
Each cube area can have a custom sky texture that replaces the vanilla sky while the player is inside the area. The texture fades in smoothly on entry and fades out on exit. The transition speed is fixed at 0.1 per tick.
How it works
The SkyboxManager tracks which areas the player is currently inside and which
one should currently display a skybox (highest priority area with a skybox assigned).
Two mixins are used to intercept rendering:
- SkyRendererMixin — replaces the vanilla sky with a sphere rendered from the skybox texture.
- CloudRendererMixin — suppresses cloud rendering while a skybox is active.
The skybox sphere is built using a static VertexBuffer and rendered with the
texture sampled from the PNG file on the client's disk.
Asset path
Skybox PNG files must be placed at:
.minecraft/config/ProtectedArea/assets/skybox/<name>.png
The <name> must match exactly the name set on the area via
/area cube skybox add <area_id> <name>.
If the file is not found, the vanilla sky is shown instead without error.
Setup
# 1. Assign the skybox to an area (server-side)
/area cube skybox add spawn night
# 2. Players need the texture at:
# .minecraft/config/ProtectedArea/assets/skybox/night.png
# 3. Remove the skybox
/area cube skybox remove spawn
Debug HUD
The Debug HUD is a 210-pixel-wide panel rendered in the top-right corner of the screen.
It is enabled per-player via /area cube debug <player> true and shows
live information about the area the player is currently standing in.
The HUD has five pages. Navigate between them using the arrow keys:
- Right Arrow — next page
- Left Arrow — previous page
These bindings are configurable in Minecraft's controls menu under the "Protected Area" category.
- Current area ID (or "none")
- Total areas loaded
- Player X Y Z position
- All active basic rules
- Marks rules where the player has an exception
- All exceptions the player has in the current area
- Current player count and maximum
- Block status (Open / BLOCKED)
- Whether the player has a limit exception
- All active advanced rule types
- Blocks and entities per rule
Commands
/area cube debug Marquinho true # Enable the HUD for Marquinho
/area cube debug @a false # Disable for all players
Physical Barriers
The no_entry and no_exit basic rules create invisible
collision walls at the boundary of an area. Unlike server-side teleport-back approaches,
these barriers work by intercepting the player's movement before it is applied,
resulting in smooth, immediate stopping without visual teleporting.
How it works
A mixin (EntityMixin) injects into Entity.move(), the method
called every tick to apply movement. When movement would cause the player's bounding box
to cross an area boundary with an active barrier rule, the movement vector on the
colliding axis is set to zero. The player stops exactly at the border.
Six collision boxes are constructed for each area (one per face of the bounding box). Only the faces relevant to the active rule are checked:
no_entry— the outer faces block inward movement.no_exit— the inner faces block outward movement.
After being stopped by a no_exit barrier, the client also sends a
return request to the server, which can then teleport the player back to a safe
position inside the area in case the client-side barrier is insufficient.
Exceptions
Players with a no_entry or no_exit exception — or the all
exception — are not stopped by the respective barrier. The collision check includes the
player's exception state received from the server.
| Rule | Effect | Bypass exception |
|---|---|---|
no_entry |
Movement into the area is blocked. The player stops at the outer edge. | no_entry or all |
no_exit |
Movement out of the area is blocked. The player is contained inside. | no_exit or all |
Teleport Detection
Every 10 ticks, the mod also checks whether the player has teleported into a no_entry
area (e.g. via a server-side teleport command). If so, it sends an expel request to the server,
which will move the player to a safe location outside the area.