Overview

The client mod (protectedareaclient) is a Fabric mod that runs exclusively on the player's game client. It has three responsibilities:

  • Receive and store area data sent by the server plugin.
  • Render colored outline boxes around areas in the game world.
  • Enforce no_entry and no_exit rules 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. 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

# 1. Set a color for the area
/area color spawn #4488FF Spawn Zone

# 2. Enable visualization for a player
/area view Marquinho true

# 3. Disable when no longer needed
/area view Marquinho false

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 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.

Page 1
Overview
  • Current area ID (or "none")
  • Total areas loaded
  • Player X Y Z position
Page 2
Rules
  • All active basic rules
  • Marks rules where the player has an exception
Page 3
Exceptions
  • All exceptions the player has in the current area
Page 4
Limit
  • Current player count and maximum
  • Block status (Open / BLOCKED)
  • Whether the player has a limit exception
Page 5
Advanced
  • All active advanced rule types
  • Blocks and entities per rule

How it works

Debug data is sent from the server as a packet whenever the player enters a new area or when the server admin enables debug mode. The client renders the overlay using Fabric's HudRenderCallback, drawing a background panel and text lines at a fixed position in the top-right corner. The overlay is only shown when debug mode is active for that player.

Commands

/area debug Marquinho true    # Enable the HUD for Marquinho
/area 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.