Skip to content

BuilderToolsPlugin.BuilderState

Package: com.hypixel.hytale.builtin.buildertools

public static class BuilderState

Per-player state for the builder tools system. Each connected player with builder tool permissions gets a BuilderState that manages their block selection, clipboard, undo/redo history, task queue, global mask, and prefab browsing state. Stored in a ConcurrentHashMap<UUID, BuilderState> within BuilderToolsPlugin.

Builder states are created when a player first uses builder tools and retained after disconnect for a configurable duration (toolExpireTime). On reconnection, the existing state is re-attached (retain()), preserving the player’s selection, clipboard, and history.

FieldTypeDescription
playerPlayerCurrent player entity reference.
playerRefPlayerRefCurrent player ref for packet sending.
userDataBuilderToolsUserDataPlayer’s builder tools preferences.
selectionBlockSelectionCurrent clipboard/selection data.
globalMaskBlockMaskGlobal mask applied to all operations.
undoObjectArrayFIFOQueue<ActionEntry>Undo history queue.
redoObjectArrayFIFOQueue<ActionEntry>Redo history queue.
tasksObjectArrayFIFOQueue<QueuedTask>Pending async operation queue.
taskFutureCompletableFuture<Void>Current task execution future.
randomRandomPer-player random (seed: 26061984).
activePrefabPathUUIDCurrently active prefab path UUID.
prefabListRootPathRoot path for prefab browser.
prefabListPathPathCurrent path in prefab browser.
prefabListSearchQueryStringSearch query in prefab browser.
timestamplongNanotime of state release for cleanup.

All editing operations are executed asynchronously via a task queue to ensure sequential execution on the world thread.

public <T extends Throwable> void addToQueue(
@Nonnull ThrowableTriConsumer<Ref<EntityStore>, BuilderToolsPlugin.BuilderState, ComponentAccessor<EntityStore>, T> task
)

Enqueues a task for execution. If no task is currently running, starts execution immediately via CompletableFuture.runAsync() on the player’s world executor. Protected by a StampedLock.

Undo and redo are FIFO queues of ActionEntry objects, each pairing an Action type with snapshot data. Protected by a StampedLock.

Restores the most recent action entry, moves its inverse to the redo queue, and sends a notification to the player.

Restores the most recent redo entry, moves its inverse to the undo queue, and sends a notification.

Adds an action entry to the undo queue and clears the redo queue. Enforces the historyCount limit by removing the oldest entry when full.

The BuilderState provides methods for all editing operations, each creating appropriate snapshots and pushing to undo history:

  • Selection: pos1(), pos2(), select(), update(), expand(), contract(), shift(), deselect()
  • Block operations: set(), fill(), replace(), clear(), walls(), hollow(), layer(), submerge()
  • Clipboard: copyOrCut(), paste(), rotate(), rotateArbitrary(), flip(), move(), stack()
  • Brush tools: edit() (brush use), editLine(), extendFace()
  • Transforms: transformThenPasteClipboard(), transformSelectionPoints()
  • Environment: tint(), environment()
  • Scripted brushes: placeBrushConfig(), flood()
  • Smooth: smooth() using a 3x3x3 weighted kernel

Exports metrics via STATE_METRICS_REGISTRY:

  • UUID, Username, ActivePrefabPath, Selection, TaskFuture, TaskCount, UndoCount, RedoCount
Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.