Files
Documentation/content/reference/buildertools/prefab-editor.en.md
2026-01-20 20:33:59 +01:00

4.3 KiB

title, type, weight
title type weight
Prefab Editor docs 3

The prefab editor allows creating, editing, and managing prefabricated structures that can be placed in the world.

Package: com.hypixel.hytale.builtin.buildertools.prefabeditor

Architecture

Prefab Editor
├── Session Management
│   ├── PrefabEditSession - Active edit session
│   └── PrefabEditSessionManager - Session coordinator
├── Components
│   ├── PrefabAnchor - Anchor point definitions
│   └── PrefabEditorCreationSettings
├── Interactions
│   ├── PrefabSelectionInteraction
│   └── PrefabSetAnchorInteraction
├── Systems
│   ├── PrefabDirtySystems - Track changes
│   └── PrefabMarkerProvider - Anchor markers
└── Commands
    └── PrefabEditCommand

Prefab Edit Session

Starting a Session

/prefabedit <prefab_id>

This enters prefab editing mode where:

  • Selection tools work within prefab bounds
  • Changes are tracked separately
  • Anchors can be set

PrefabEditSession

public class PrefabEditSession {
    // Active editing session for a prefab
    // Tracks modifications and anchors
}

Session Manager

PrefabEditSessionManager manager = BuilderToolsPlugin.get().getPrefabEditSessionManager();

// Check if player is editing
boolean isEditing = manager.isEditing(player);

// Get active session
PrefabEditSession session = manager.getSession(player);

Prefab Anchors

Anchors define special points within a prefab:

PrefabAnchor

public class PrefabAnchor {
    // Position relative to prefab origin
    // Name identifier
    // Anchor type
}

Setting Anchors

Use the anchor interaction or command:

/prefab anchor set <name> [x y z]
/prefab anchor remove <name>
/prefab anchor list

Anchor Types

Type Description
origin Prefab placement origin
spawn Entity spawn point
connection Connection to other prefabs
custom User-defined anchor

Prefab Commands

/prefab

Main prefab management command:

/prefab save <name>       Save selection as prefab
/prefab load <name>       Load prefab to clipboard
/prefab list              List available prefabs
/prefab delete <name>     Delete a prefab
/prefab info <name>       Show prefab information

/prefabedit

Enter prefab editing mode:

/prefabedit <prefab_id>   Edit existing prefab
/prefabedit exit          Exit editing mode
/prefabedit save          Save changes
/prefabedit discard       Discard changes

Interactions

PrefabSelectionInteraction

Select prefabs in the world:

// Registered interaction type
getCodecRegistry(Interaction.CODEC).register(
    "PrefabSelection",
    PrefabSelectionInteraction.class,
    PrefabSelectionInteraction.CODEC
);

PrefabSetAnchorInteraction

Set anchors via interaction:

// Allows clicking to place anchors
getCodecRegistry(Interaction.CODEC).register(
    "PrefabSetAnchor",
    PrefabSetAnchorInteraction.class,
    PrefabSetAnchorInteraction.CODEC
);

Creation Settings

PrefabEditorCreationSettings

Configuration for creating new prefabs:

public class PrefabEditorCreationSettings {
    // Settings for prefab creation
    // Include entities flag
    // Compression settings
}

Systems

PrefabDirtySystems

Tracks modifications to prefabs:

// Marks prefab as modified when changes occur
// Prompts save on exit

PrefabMarkerProvider

Provides visual markers for anchors:

// Displays anchor positions in creative mode
// Shows connection points

API Usage

Save Selection as Prefab

BuilderToolsPlugin tools = BuilderToolsPlugin.get();
// Selection must be defined first
// Use /prefab save command or API

Load and Place Prefab

// Load to clipboard
// /prefab load <name>

// Paste at location
// /paste

Check Edit Mode

PrefabEditSessionManager manager =
    BuilderToolsPlugin.get().getPrefabEditSessionManager();

if (manager.isEditing(player)) {
    PrefabEditSession session = manager.getSession(player);
    // Work with session
}

Prefab Storage

Prefabs are stored in the world data:

worlds/<world>/prefabs/<name>.prefab

Structure includes:

  • Block data
  • Entity data (if included)
  • Anchor definitions
  • Metadata