Skip to main content

Camera, HUD, input locks

Concept​

The camera, HUD elements and input are all controlled with packets the server sends only to one player's client. In BDS the /camera command and the Script API do the same job, and a custom server sends the packets directly. The world does not change, so other players are not affected. The packets below follow the gophertunnel (MIT) definitions. (Source: gophertunnel-repo, minecraft/protocol/packet)

CameraInstruction packet​

All fields of CameraInstruction are optional, so one packet can carry several commands.

FieldDescription
SetSet the camera to a given preset (position, rotation, transition time and so on)
ClearIf true, clear all camera commands
FadeFade the screen to a given color
TargetAim at a specific entity
RemoveTargetIf true, clear the current target
FieldOfViewUpdate the field of view
SplineSpline path for the camera to follow
AttachToEntityID of the entity to attach the camera to
DetachFromEntityIf true, detach from the current entity

Presets are announced in advance with the CameraPresets packet at join. A common approach is to send one free camera preset at start and then change position and rotation with Set.

SetHud and UpdateClientInputLocks​

// hide or restore HUD elements
&packet.SetHud{Elements: []int32{packet.HudElementHotBar, packet.HudElementHealth}, Visibility: packet.HudVisibilityHide}
// input lock: a combination of flags, 0 clears everything
&packet.UpdateClientInputLocks{Locks: packet.ClientInputLockCamera | packet.ClientInputLockMovement}
HUD element constantIndex
HudElementPaperDoll0
HudElementArmour1
HudElementToolTips2
HudElementTouchControls3
HudElementCrosshair4
HudElementHotBar5
HudElementHealth6
HudElementProgressBar7
HudElementHunger8
HudElementAirBubbles9
HudElementHorseHealth10
HudElementStatusEffects11
HudElementItemText12

Visibility is HudVisibilityHide (0) or HudVisibilityReset (1). The input lock flags are ClientInputLockCamera, Movement, LateralMovement, Sneak, Jump, Mount, Dismount, MoveForward, MoveBackward, MoveLeft, MoveRight (bits starting from 1 << (iota+1), with one bit left empty). Even if you hide with SetHud, elements a resource pack added to the HUD (such as the sidebar) remain.

Screen control for one player in Dragonfly (packet hooks)​

Dragonfly has no such API, so you build hooks that send packets to the session. All of them are sent only to one player's client. (Source: private research)

What it doesHow
Move the camera to a position and rotationCameraInstruction.Set with the free camera preset sent at join (including easing time). Meanwhile the movement keys are relative to the camera
Return the camera to normalCameraInstruction.Clear
Change and restore the field of viewCameraInstruction.FieldOfView
Hide all vanilla HUDSetHud with all elements. Resource pack HUD elements remain
Input lockUpdateClientInputLocks, 0 clears
Play a resource pack animation once for only that playerAnimateEntity to that client only (similar to the script playAnimation)
A player model that exists in no worldfake-blocks-and-chunks.mdx
Title and subtitleSend the subtitle before the title, because the client shows the subtitle together with the next title. If sent as a raw JSON title, the client converts translation keys into its own language

To follow a player from above with a camera, instead of resending Set every tick (for example every other tick at 72 degrees, 16 blocks up, 0.1 s easing), use the client's minecraft:fixed_boom preset so the client follows the player itself. A preset based on follow_orbit (60 degrees down, 12 blocks) serves the same purpose [code, not yet checked in game].

Camera spline (real client) [measured]​

Results of sending CameraInstruction.Spline from a server and testing it in a real client (gophertunnel v1.63.0 server, 2026-11-14, platform not recorded).

  • The position curve is not used: the client did not use the position curve of a server-sent spline, only its rotation key frames. With two points, duplicated end points, progress as control point indices, five distinct points with cumulative distance progress, eye-relative coordinates, the linear type, the end point 6 blocks above the eyes, and progress times as fractions or ticks, the camera always went to the player's first-person position and only rotated for 1.5 s.
  • A free camera Set must come first: a spline alone without Set did nothing. There is a report that a spline in the same tick as Set is ignored (MCPE-173524; MiNET sends it a second later). With a 1 s wait, the Set view held for 1 s, then the spline started and the position changed at once.
  • Removing the progress key frames crashed the client.
  • Rotation value order: sending (pitch, yaw) rotated left and right; (yaw, pitch) rotated up and down. MiNET uses (pitch, yaw, roll) with positive pitch up.
  • Protocol definition: per Mojang bedrock-protocol-docs, control points are world coordinates, progress is 0 to 1 over the whole curve, and SplineType 0 is Catmull-Rom and 1 is linear. A working example (Mcblend) uses Catmull-Rom with at least four distinct points, removes consecutive duplicate points (they break the client), gives progress as the cumulative distance ratio, and uses linear below four points [code].
  • gophertunnel v1.63.0 field issue: gophertunnel v1.63.0 writes the spline's SplineType, SplineIdentifier and LoadFromJson as optional fields, and the client reads the packet correctly only when all three are empty. Setting a value misaligns the packet. To change the type, write the spline packet yourself in the layout the client reads, and test that the default type is byte-identical to gophertunnel.
  • What works instead: chaining eased (sine in-out) Set moves, one per stop.

Locator bar [measured]​

Turning on the locator bar rule with GameRulesChanged and sending waypoints with LocatorBar and PlayerLocation from a custom server did not show the bar in a real client (2026-11-14). The rule names locatorbar, locatorBar, playerWaypoints and locator_bar all gave the same result. Other game rules are sent lowercase (dodaylightcycle, showcoordinates), and Dragonfly's level.dat key is also locatorbar. The vanilla HUD draws the bar in place of the XP bar only when #hotbar_with_locator_bar is true. Turning on locatorbar and locatorBar in the StartGame game rules has no recorded result {unverified}.

More observations on forms and HUD (server development measurements)​

Screen host​

  • Form screen animation [measured]: "$screen_animations": [] and "$background_animations": [] on third_party_server_screen. If the next form arrived while the window was moving, the two windows appeared overlapping, and a form that closes and reopens flickered.
  • Background behind a form [measured]: Change $screen_bg_content of third_party_server_screen (outside the safe zone, not pushed during screen transitions) to draw the frame you want behind the form. If the #title_text binding there is set to once, it was evaluated before the form content arrived and nothing showed.
  • Sidebar scoreboard as a HUD channel [measured]: Attach a marker (§d§h§u§d) to the objective name and partial markers (§d§1 to §d§4) to each line. scoreboards.json turns scoreboard_sidebar into a full-screen panel and draws each part by splitting it with a scoreboard_players collection stack (#scoreboard_sidebar_size as #collection_length). The client merges lines with the same text, so append §r to tell them apart (up to 15 lines). It does not overwrite the title.
  • Form while the HUD is hidden [measured]: While a form is open, the HUD is not drawn. To show the same frame behind the form as well, draw it in the form background ($screen_bg_content) too.

Miscellaneous facts about forms and HUD​

  • Vanilla confirmation form [record]: A modal form (modal_form) does not take the server_form.json theme and appeared as a light default window. Confirm and cancel were sent as the two buttons of an action form.
  • Grid height [record]: If the grid height was set to #form_button_contents or default, no buttons appeared at all. Use 100%c.
  • 100%c in a horizontal stack [record]: The height 100%c of a horizontal stack adds up all child heights, leaving a large gap under the tab row. Use 100%cm, which follows the largest child.
  • Numeric variable inside a size array [record]: Putting a numeric variable inside an array such as "size": [ "$w", "100%c" ] gave a "Dangling number" error. Give the size as a variable for the whole array ("size": "$window_size").
  • Input form text [record]: The text of the vanilla input field is white, so it is invisible on a light card.
  • Text that holds only a number [record]: Values that read as numbers (" 219", "1,532/4,096") did not show in a label. Send them as text that starts with a color code, or make them a string with '§r' + value inside a variable expression. A one-digit numeric flag also becomes a number and breaks text comparison, so write flags as letters (a to k).
  • Expressions in the variables block [record]: A count expression only evaluated when placed in the label's own variables block. Expressions in the parent panel's variables or ('§r' + $variable) inside text were not evaluated. Using an expression from a variables block inside another expression was also not evaluated.
  • Drawing an item with the HUD subtitle [record]: When carrying item runtime ID x 65536 in the title's subtitle to draw an icon, it was drawn when cut with '%.11s' from the variable $var_subtitle_text that the title factory provides and put into #item_id_aux of property_bag. In the earlier setup, taking the slot from the binding #hud_subtitle_text_string left the icon empty with every approach (cutting, fixed width, adding and subtracting, erasing the padding characters). In a later test, with #item_id_aux: 0 in property_bag and a view binding from #hud_subtitle_text_string to #item_id_aux with binding_condition: "always", the icon was drawn (measured, section 3.4 of HUD item icons). The difference between the two setups was not checked {unverified}. Sending the subtitle as digits only broke the vanilla block-state slot check and gave an "expected a string" warning.
  • Toast [record]: The client shows toasts one at a time in turn. Toasts show even while a form is open and do not block the next form.
  • Item use repetition [record]: While the use button is held, the client repeatedly sends the item use packet. If you send a form on every use, the same form piles up and the next one appears each time you close one.
  • HUD hidden with SetHud [record]: Even if you hide the vanilla HUD with SetHud, elements a resource pack added to the HUD remain.
  • Pocket layout [record]: On a touch screen, when the UI profile is pocket, the vanilla HUD draws hearts at the top left and hunger at the top right through not_centered_gui_elements. You can redefine that version in hud_screen.json and move to the classic touch layout (the same place as centered_gui_elements_at_bottom_middle_touch).
  • Dimming the screen [record]: Vanilla dims the area behind a form with screen_background at opacity 0.4.
  • Quick move button [record]: If you stack one visible button next to the chest window and as many invisible buttons as there are slots under it, and change each button's press into that slot's vanilla quick move (button.container_auto_place, consume_event: false), one click becomes a shift-click on every slot (a technique from the Quick Container pack). The server receives a plain item move request per slot. There is also an example in ../bedrock-core/samples/pack.chest.json.
  • Slot decoration (markers in item names) [record]: JSON UI cannot read a slot's item data; it reads only the slot collection's #hover_text (name + description). If you put a marker with §r right after §k, such as §k§r§a, in an item name, nothing remains on screen, and you can add the binding (not ((#hover_text - 'marker') = #hover_text)) * number to make a number and pick a texture.
    • The slot template needs changes in two places: container_item (ui_common.json, chests and so on) and inventory_container_item (inventory_screen.json, bag and crafting slots). The latter has its own controls, so a change to the former does not reach it. The layers are slot background 1 and item 7, so put the back decoration at 6 and the front decoration at 9.
    • The PC hover box is drawn by the engine and its frame cannot be changed. On the touch UI's selected item bubble (item_panel_image), you can draw over it.
    • The color code of a marker continues into the following text, so if you put a name containing a marker in the middle of a sentence, the color bleeds.
Sources
idSourceLicenseCommitAccessed
private-researchPrivate research (-)-2026-11-13
gophertunnelgophertunnel (Sandertv)MIT (c) 2019 Sandertve2251a62026-11-13
dragonflyDragonfly (df-mc)MITd86aefd (baseline of a patch for one Dragonfly-based server)2026-11-13