Token导航 LogoToken导航

Agent Skill · 研究检索

hytale-ui-windows(hytale ui 窗口)

用于辅助界面设计、视觉规范、排版、配色、布局和交互体验优化。它适合让 Agent 根据产品场景整理页面结构、生成 UI 方案、检查视觉一致性或改进组件层级。使用时需要结合现有品牌、设计系统和用户任务,不应只堆装饰元素;涉及真实页面改动时,应通过截图或浏览器预览检查文本溢出、对齐和响应式表现。

hytale-ui-windows 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证为 MIT,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 55,572。

总安装 474周安装 19GitHub Stars 3下载 154核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:hytale-ui-windows(hytale ui 窗口)
来源仓库:https://github.com/mnkyarts/hytale-skills
仓库路径:skills/hytale-ui-windows
安装命令:
npx skills add https://github.com/mnkyarts/hytale-skills --skill hytale-ui-windows
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/mnkyarts/hytale-skills --skill hytale-ui-windows

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于辅助界面设计、视觉规范、排版、配色、布局和交互体验优化,适合让 Agent 根据产品场景整理页面结构或改进组件层级。适用于 UI 设计、视觉规范和用户体验优化等场景,帮助 Agent 提升界面质量。

使用时需要结合现有品牌、设计系统和用户任务,不应只堆装饰元素;涉及真实页面改动时,应通过截图或浏览器预览检查文本溢出、对齐和响应式表现。通过 npx skills add 命令从指定 GitHub 仓库安装,需结合原始 README 核验具体用法和功能细节。

可结合来源仓库和 SKILL.md 继续核验具体用法,确保与当前宿主环境兼容。

来源仓库内路径:skills/hytale-ui-windows

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/mnkyarts/hytale-skills --skill hytale-ui-windo…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

hytale-ui-windows 怎么安装?

在终端执行 npx skills add https://github.com/mnkyarts/hytale-skills --skill hytale-ui-windows。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

hytale-ui-windows 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

hytale-ui-windows 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

hytale-ui-windows 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

hytale-ui-windows 用的人多吗?

公开数据是累计安装 474 次,近一周安装 19 次,下载 154 次,GitHub 3 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

hytale-ui-windows 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。
  • 需要许可证清楚、并且有第三方扫描结果的团队项目。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
hytale-ui-windows

hytale ui 窗口 · 本页

4743只读MIT通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Hytale UI Windows

Complete guide for creating custom UI windows, container interfaces, and interactive menus in Hytale server plugins.

When to use this skill

Use this skill when:

  • Creating custom inventory windows
  • Building container interfaces (chests, benches)
  • Implementing crafting UI systems
  • Making interactive menus
  • Handling window actions and clicks
  • Syncing window state between server and client
  • Creating.ui layout files for custom pages
  • Designing HUD elements and overlays

UI System Overview

Hytale's UI system consists of two main approaches:

  1. Window System (Java) - For inventory containers, crafting benches, and block-tied UIs

- Uses Window classes with WindowManager - Sends JSON data via getData() - Handles predefined WindowAction types

  1. Custom UI Pages (Java) - For dynamic forms, lists, dialogs, and interactive pages

- Uses CustomUIPage classes with PageManager - Loads .ui files dynamically via UICommandBuilder - Binds events with typed data via UIEventBuilder

Both systems use client-side.ui files to define visual layout and styling.

.ui Files

UI files (.ui) are client-side layout files that define the visual structure of windows and pages. They use a declarative syntax with:

  • Variables (@Name = value;) - Reusable values and styles
  • Imports ($C = "path/to/file.ui";) - Reference other UI files
  • Elements (WidgetType {properties}) - UI widgets with nested children
  • Templates ($C.@TemplateName {overrides}) - Instantiate reusable components

IMPORTANT: File Location

All .ui files MUST be placed in resources/Common/UI/Custom/ in your plugin JAR.

your-plugin/
  src/main/resources/
    manifest.json                    # Must have "IncludesAssetPack": true
    Common/
      UI/
        Custom/
          MyPage.ui                  # Your custom UI files go here
          MyHud.ui
          ListItem.ui

Requirements:

  1. Your manifest.json MUST contain "IncludesAssetPack": true
  2. UI files go in resources/Common/UI/Custom/ (NOT assets/Server/Content/UI/Custom/)
  3. In Java code, reference files by filename only: commandBuilder.append("MyPage.ui")

Common Error: Could not find document XXXXX for Custom UI Append command

  • This means your .ui file is not in Common/UI/Custom/ or the path is wrong
  • Double-check the file location and that IncludesAssetPack is set to true

Basic.ui File Structure

$C = "../Common.ui";

$C.@PageOverlay {}                    // Dark background overlay

$C.@Container {
  Anchor: (Width: 600, Height: 400);

  #Title {
    $C.@Title { @Text = %page.title; }
  }

  #Content {
    LayoutMode: Top;

    Label #ValueLabel { Text: ""; }   // ID for code access

    $C.@TextButton #ActionBtn {
      @Text = %page.action;
    }
  }
}

$C.@BackButton {}

Key Concepts

SyntaxPurposeExample
@Var = value;Variable definition@FontSize = 16;
$Alias = "path";Import file$C = "../Common.ui";
$C.@Template {}Use template$C.@TextButton {}
#ElementIdElement ID for codeLabel #Title {}
%key.pathTranslation keyText: %ui.title;
...@StyleSpread/extendStyle: (...@Base, Bold: true);

See references/ui-file-syntax.md for complete.ui file documentation.

Window Architecture Overview

Hytale uses a window system for server-controlled UI. Windows are opened server-side and rendered client-side, with actions sent back to the server for processing. Window data is transmitted as JSON and inventory contents are synced separately.

Window Class Hierarchy

Window (abstract)
├── ContainerWindow                  # Simple item container (implements ItemContainerWindow)
├── ItemStackContainerWindow         # Container tied to an ItemStack (implements ItemContainerWindow)
├── FieldCraftingWindow              # Pocket/inventory crafting (WindowType.PocketCrafting)
├── MemoriesWindow                   # Memories/achievements display (WindowType.Memories)
└── BlockWindow (abstract)           # Tied to a block in the world (implements ValidatedWindow)
    ├── ContainerBlockWindow         # Container tied to a block (implements ItemContainerWindow)
    └── BenchWindow (abstract)       # Crafting bench base (implements MaterialContainerWindow)
        ├── ProcessingBenchWindow    # Furnace-like processing (implements ItemContainerWindow)
        └── CraftingWindow (abstract)
            ├── SimpleCraftingWindow       # Basic workbench crafting (implements MaterialContainerWindow)
            ├── DiagramCraftingWindow      # Blueprint/anvil crafting (implements ItemContainerWindow)
            └── StructuralCraftingWindow   # Block transformation crafting (implements ItemContainerWindow)

Key Interfaces

InterfacePurpose
ItemContainerWindowWindows with item inventory slots
MaterialContainerWindowWindows with extra resource materials
ValidatedWindowWindows that validate state (e.g., player distance)

Window Types (WindowType Enum)

WindowTypeValueDescriptionUse Case
Container0Item storageChests, backpacks
PocketCrafting1Field craftingPlayer inventory crafting
BasicCrafting2Standard craftingCrafting tables
DiagramCrafting3Blueprint-basedAdvanced workbenches, anvils
StructuralCrafting4Block transformationStonecutters, construction benches
Processing5Time-based conversionFurnaces, smelters
Memories6Special displayMemory/achievement UI

Window Flow

Server: openWindow(window) -> OpenWindow packet (ID 200) -> Client: Render UI
Client: User Action -> SendWindowAction packet (ID 203) -> Server: handleAction()
Server: invalidate() -> updateWindows() -> UpdateWindow packet (ID 201) -> Client: Refresh UI
Server: closeWindow() -> CloseWindow packet (ID 202) -> Client: Close UI

Window Data Pattern

Windows use getData() to return a JsonObject that is serialized and sent to the client. This data controls client-side rendering:

@Override
public JsonObject getData() {
    JsonObject data = new JsonObject();
    data.addProperty("type", windowType.ordinal());
    data.addProperty("title", "My Window");
    data.addProperty("customProperty", someValue);
    return data;
}

Basic Window Implementation

Abstract Window Base

All windows extend from Window and must implement these abstract methods:

package com.example.myplugin.windows;

import com.google.gson.JsonObject;
import com.hypixel.hytale.server.core.entity.entities.player.windows.Window;
import com.hypixel.hytale.protocol.packets.window.WindowType;
import com.hypixel.hytale.protocol.packets.window.WindowAction;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;

public class CustomWindow extends Window {

    private final JsonObject windowData = new JsonObject();

    public CustomWindow() {
        super(WindowType.Container);
        // Initialize window data
        windowData.addProperty("title", "Custom Window");
    }

    @Override
    public JsonObject getData() {
        // Return data to send to client (serialized as JSON)
        return windowData;
    }

    @Override
    protected boolean onOpen0() {
        // Called when window opens
        // Return false to cancel opening
        return true;
    }

    @Override
    protected void onClose0() {
        // Called when window closes - cleanup here
    }

    @Override
    public void handleAction(Ref<EntityStore> ref, Store<EntityStore> store, WindowAction action) {
        // Handle window actions from client
        // Default implementation is no-op
    }
}

Opening Windows

Windows are opened through the WindowManager:

import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.entities.player.windows.WindowManager;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.protocol.packets.window.OpenWindow;
import javax.annotation.Nonnull;

public class StorageCommand extends AbstractPlayerCommand {

    public StorageCommand() {
        super("storage", "Open storage window");
    }

    @Override
    protected void execute(
        @Nonnull CommandContext context,
        @Nonnull Store<EntityStore> store,
        @Nonnull Ref<EntityStore> ref,
        @Nonnull PlayerRef playerRef,
        @Nonnull World world
    ) {
        world.execute(() -> {
            Player player = store.getComponent(ref, Player.getComponentType());
            StorageWindow window = new StorageWindow();

            // Open via WindowManager
            WindowManager windowManager = player.getWindowManager();
            OpenWindow packet = windowManager.openWindow(window);

            if (packet != null) {
                // Window opened successfully - packet is sent automatically
                context.sendSuccess("Window opened!");
            } else {
                // Opening was cancelled (onOpen0() returned false)
                context.sendError("Failed to open window");
            }
        });
    }
}

Updating Windows

Mark a window as needing update with invalidate():

public void updateData(String newValue) {
    windowData.addProperty("value", newValue);
    invalidate(); // Mark for update
}

// For full rebuild (client re-renders entire window)
public void requireRebuild() {
    setNeedRebuild();
    invalidate();
}

Updates are batched and sent via WindowManager.updateWindows() which checks isDirty flag.

Window Manager

The WindowManager handles window lifecycle for each player:

// Get player's window manager
WindowManager windowManager = player.getWindowManager();

// Open a window (returns OpenWindow packet or null if cancelled)
OpenWindow packet = windowManager.openWindow(new MyWindow());

// Open multiple windows atomically (all or none)
List<OpenWindow> packets = windowManager.openWindows(window1, window2);

// Get window by ID
Window window = windowManager.getWindow(windowId);

// Get all open windows
List<Window> windows = windowManager.getWindows();

// Update a specific window (sends UpdateWindow packet)
windowManager.updateWindow(window);

// Update all dirty windows
windowManager.updateWindows();

// Validate all ValidatedWindow instances (closes invalid ones)
windowManager.validateWindows();

// Close a specific window
windowManager.closeWindow(windowId);

// Close all windows
windowManager.closeAllWindows();

// Mark a window as changed
windowManager.markWindowChanged(windowId);

Window IDs

  • ID 0 is reserved for client-requested windows
  • ID -1 is invalid
  • Server-assigned IDs start at 1 and increment

Block Windows

Windows tied to blocks in the world (chests, crafting tables). Extends BlockWindow which implements ValidatedWindow:

public class CustomChestWindow extends BlockWindow implements ItemContainerWindow {

    private final SimpleItemContainer itemContainer;
    private final JsonObject windowData = new JsonObject();

    public CustomChestWindow(int x, int y, int z, int rotationIndex, BlockType blockType) {
        super(WindowType.Container, x, y, z, rotationIndex, blockType);
        this.itemContainer = new SimpleItemContainer(27); // 3 rows

        // Set max interaction distance (default: 7.0)
        setMaxDistance(7.0);

        // Initialize window data
        Item item = blockType.getItem();
        windowData.addProperty("blockItemId", item != null ? item.getId() : "");
    }

    @Override
    public JsonObject getData() {
        return windowData;
    }

    @Override
    public ItemContainer getItemContainer() {
        return itemContainer;
    }

    @Override
    protected boolean onOpen0() {
        // Load chest contents from block entity
        PlayerRef playerRef = getPlayerRef();
        Ref<EntityStore> ref = playerRef.getReference();
        Store<EntityStore> store = ref.getStore();
        World world = store.getExternalData().getWorld();

        // Load items from persistent storage
        loadItemsFromWorld(world);
        return true;
    }

    @Override
    protected void onClose0() {
        // Save chest contents
        saveItemsToWorld();
    }
}

Block Validation

BlockWindow automatically validates that:

  1. Player is within maxDistance of the block (default 7.0 blocks)
  2. The block still exists in the world
  3. The block type matches (via item comparison)

When validation fails, the window is automatically closed.

Block Interaction Handler

@EventHandler
public void onBlockInteract(BlockInteractEvent event) {
    Player player = event.getPlayer();
    BlockPos pos = event.getBlockPos();
    Block block = event.getBlock();

    if (block.getType().getId().equals("my_mod:custom_chest")) {
        CustomChestWindow window = new CustomChestWindow(
            pos.x(), pos.y(), pos.z(),
            block.getRotationIndex(),
            block.getType()
        );
        player.getWindowManager().openWindow(window);
        event.setCancelled(true);
    }
}

Crafting Windows

BenchWindow Base

All crafting bench windows extend BenchWindow:

public abstract class BenchWindow extends BlockWindow implements MaterialContainerWindow {
    protected final Bench bench;
    protected final BenchState benchState;
    protected final JsonObject windowData = new JsonObject();
    private MaterialExtraResourcesSection extraResourcesSection;

    // Window data includes:
    // - type: bench type ordinal
    // - id: bench ID string
    // - name: translation key
    // - blockItemId: item ID
    // - tierLevel: current tier level
    // - worldMemoriesLevel: world memories level
    // - progress: crafting progress (0.0 - 1.0)
    // - tierUpgradeProgress: tier upgrade progress
}

SimpleCraftingWindow (Basic Workbench)

public class WorkbenchWindow extends SimpleCraftingWindow {

    public WorkbenchWindow(BenchState benchState) {
        super(benchState);
    }

    @Override
    public void handleAction(Ref<EntityStore> ref, Store<EntityStore> store, WindowAction action) {
        if (action instanceof CraftRecipeAction craftAction) {
            String recipeId = craftAction.recipeId;
            int quantity = craftAction.quantity;
            // Handle crafting
            CraftingManager craftingManager = store.getComponent(ref, CraftingManager.getComponentType());
            craftSimpleItem(store, ref, craftingManager, craftAction);
        } else if (action instanceof TierUpgradeAction) {
            // Handle bench tier upgrade
            handleTierUpgrade(ref, store);
        }
    }
}

ProcessingBenchWindow (Furnace-like)

public class SmelterWindow extends ProcessingBenchWindow {

    public SmelterWindow(BenchState benchState) {
        super(benchState);
    }

    // ProcessingBenchWindow provides:
    // - setActive(boolean): toggle processing
    // - setProgress(float): update progress (0.0 - 1.0)
    // - setFuelTime(float): current fuel remaining
    // - setMaxFuel(int): maximum fuel capacity
    // - setProcessingSlots(Set<Short>): slots currently processing
    // - setProcessingFuelSlots(Set<Short>): fuel slots in use

    @Override
    public void handleAction(Ref<EntityStore> ref, Store<EntityStore> store, WindowAction action) {
        if (action instanceof SetActiveAction activeAction) {
            setActive(activeAction.state);
            invalidate();
        } else if (action instanceof TierUpgradeAction) {
            handleTierUpgrade(ref, store);
        }
    }
}

Updating Crafting Progress

// Update progress with throttling (min 5% change or 500ms interval)
public void updateCraftingJob(float percent) {
    windowData.addProperty("progress", percent);
    checkProgressInvalidate(percent);
}

public void updateBenchUpgradeJob(float percent) {
    windowData.addProperty("tierUpgradeProgress", percent);
    checkProgressInvalidate(percent);
}

// On tier level change (requires full rebuild)
public void updateBenchTierLevel(int newValue) {
    windowData.addProperty("tierLevel", newValue);
    updateBenchUpgradeJob(0.0f);
    setNeedRebuild();
    invalidate();
}

Item Container Windows

Windows with inventory slots implement ItemContainerWindow:

public interface ItemContainerWindow {
    @Nonnull ItemContainer getItemContainer();
}

ItemContainer Integration

public class InventoryWindow extends Window implements ItemContainerWindow {

    private final SimpleItemContainer itemContainer;
    private final JsonObject windowData = new JsonObject();

    public InventoryWindow(int size) {
        super(WindowType.Container);
        this.itemContainer = new SimpleItemContainer(size);

        // Register change listener for automatic updates
        itemContainer.registerChangeEvent(EventPriority.NORMAL, event -> {
            invalidate();
        });
    }

    @Override
    public ItemContainer getItemContainer() {
        return itemContainer;
    }

    @Override
    public JsonObject getData() {
        return windowData;
    }

    @Override
    protected boolean onOpen0() {
        return true;
    }

    @Override
    protected void onClose0() {
        // Cleanup
    }
}

Note: When a window implements ItemContainerWindow, the WindowManager automatically:

  1. Registers a change listener to mark the window dirty when inventory changes
  2. Includes InventorySection in OpenWindow and UpdateWindow packets
  3. Unregisters the listener when the window closes

Window Actions

Handle user interactions with handleAction():

@Override
public void handleAction(Ref<EntityStore> ref, Store<EntityStore> store, WindowAction action) {
    if (action instanceof CraftRecipeAction craft) {
        handleCraft(craft.recipeId, craft.quantity);
    } else if (action instanceof SelectSlotAction select) {
        handleSlotSelect(select.slot);
    } else if (action instanceof SetActiveAction active) {
        handleActiveToggle(active.state);
    } else if (action instanceof SortItemsAction sort) {
        handleSort(sort.sortType);
    }
}

WindowAction Types

Type IDClassFieldsDescription
0CraftRecipeActionrecipeId: String, quantity: intCraft a recipe
1TierUpgradeAction(none)Upgrade bench tier
2SelectSlotActionslot: intSelect a slot
3ChangeBlockActiondown: booleanCycle block type direction
4SetActiveActionstate: booleanToggle processing on/off
5CraftItemAction(none)Confirm diagram crafting
6UpdateCategoryActioncategory: String, itemCategory: StringChange recipe category
7CancelCraftingAction(none)Cancel current crafting
8SortItemsActionsortType: SortTypeSort inventory items

SortType Enum

public enum SortType {
    Name(0),   // Sort by item translation key
    Type(1),   // Sort by item type (Weapon, Armor, Tool, Item, Special)
    Rarity(2); // Sort by quality value (reversed)
}

Window Packets

Network communication for windows:

Server to Client

PacketIDFieldsPurpose
OpenWindow200id, windowType, windowData, inventory, extraResourcesOpen window on client
UpdateWindow201id, windowData, inventory, extraResourcesUpdate window contents
CloseWindow202idClose window on client

Client to Server

PacketIDFieldsPurpose
SendWindowAction203id, action: WindowActionUser interaction
ClientOpenWindow204type: WindowTypeRequest client-initiated window

Packet Structure

The OpenWindow packet includes:

  • windowData: JSON string with window-specific data
  • inventory: InventorySection (nullable) - only for ItemContainerWindow
  • extraResources: ExtraResources (nullable) - only for MaterialContainerWindow
// Creating OpenWindow packet (done automatically by WindowManager)
OpenWindow packet = new OpenWindow(
    windowId,
    window.getType(),
    window.getData().toString(),  // JSON string
    itemContainerWindow != null ? itemContainerWindow.getItemContainer().toPacket() : null,
    materialContainerWindow != null ? materialContainerWindow.getExtraResourcesSection().toPacket() : null
);

Client-Requestable Windows

Some windows can be opened by client request (e.g., pressing a key). Register these in Window.CLIENT_REQUESTABLE_WINDOW_TYPES:

public class MyPlugin extends JavaPlugin {

    @Override
    protected void setup() {
        // Register client-requestable window
        Window.CLIENT_REQUESTABLE_WINDOW_TYPES.put(
            WindowType.Memories,
            MemoriesWindow::new
        );
    }
}

When client sends ClientOpenWindow packet, the server:

  1. Looks up the WindowType in CLIENT_REQUESTABLE_WINDOW_TYPES
  2. Creates a new window instance using the supplier
  3. Opens it with ID 0 via windowManager.clientOpenWindow(window)
// Handle client-requested window
@PacketHandler
public void onClientOpenWindow(ClientOpenWindow packet) {
    Supplier<? extends Window> supplier = Window.CLIENT_REQUESTABLE_WINDOW_TYPES.get(packet.type);
    if (supplier != null) {
        Window window = supplier.get();
        UpdateWindow updatePacket = windowManager.clientOpenWindow(window);
        if (updatePacket != null) {
            player.sendPacket(updatePacket);
        }
    }
}

Custom Window Rendering

Define window appearance through getData():

public class CustomMenuWindow extends Window {

    private final JsonObject windowData = new JsonObject();

    public CustomMenuWindow() {
        super(WindowType.Container);
        setupLayout();
    }

    @Override
    public JsonObject getData() {
        return windowData;
    }

    private void setupLayout() {
        windowData.addProperty("title", "Main Menu");
        windowData.addProperty("rows", 6);

        // Add custom properties for client rendering
        JsonArray menuItems = new JsonArray();
        menuItems.add(createMenuItem("pvp", "PvP Arena", "diamond_sword", 20));
        menuItems.add(createMenuItem("survival", "Survival", "grass_block", 22));
        menuItems.add(createMenuItem("lobby", "Lobby", "ender_pearl", 24));
        windowData.add("menuItems", menuItems);
    }

    private JsonObject createMenuItem(String id, String name, String icon, int slot) {
        JsonObject item = new JsonObject();
        item.addProperty("id", id);
        item.addProperty("name", name);
        item.addProperty("icon", icon);
        item.addProperty("slot", slot);
        return item;
    }

    @Override
    public void handleAction(Ref<EntityStore> ref, Store<EntityStore> store, WindowAction action) {
        if (action instanceof SelectSlotAction select) {
            switch (select.slot) {
                case 20 -> joinPvP(ref, store);
                case 22 -> joinSurvival(ref, store);
                case 24 -> teleportToLobby(ref, store);
            }
        }
    }

    @Override
    protected boolean onOpen0() { return true; }

    @Override
    protected void onClose0() { }
}

Material Container Windows

Windows with extra resource materials implement MaterialContainerWindow:

public interface MaterialContainerWindow {
    @Nonnull MaterialExtraResourcesSection getExtraResourcesSection();
    void invalidateExtraResources();
    boolean isValid();
}

MaterialExtraResourcesSection

public class MaterialExtraResourcesSection {
    private boolean valid;
    private ItemContainer itemContainer;
    private ItemQuantity[] extraMaterials;

    // Methods
    public void setExtraMaterials(ItemQuantity[] materials);
    public ExtraResources toPacket();
    public boolean isValid();
    public void setValid(boolean valid);
}

Usage in crafting windows:

@Override
public MaterialExtraResourcesSection getExtraResourcesSection() {
    if (!extraResourcesSection.isValid()) {
        // Recompute extra materials from bench state
        CraftingManager.feedExtraResourcesSection(benchState, extraResourcesSection);
    }
    return extraResourcesSection;
}

@Override
public void invalidateExtraResources() {
    extraResourcesSection.setValid(false);
    invalidate();
}

Close Event Registration

Register handlers for when a window closes:

public class MyWindow extends Window {

    @Override
    protected boolean onOpen0() {
        // Register close event handler
        registerCloseEvent(event -> {
            // Called when window closes
            saveData();
            cleanupResources();
        });

        // With priority
        registerCloseEvent(EventPriority.FIRST, event -> {
            // Called first
        });

        return true;
    }
}

Complete Example: Container Block Window

package com.example.storage;

import com.google.gson.JsonObject;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.protocol.packets.window.WindowAction;
import com.hypixel.hytale.protocol.packets.window.WindowType;
import com.hypixel.hytale.protocol.packets.window.SortItemsAction;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.entity.entities.player.windows.BlockWindow;
import com.hypixel.hytale.server.core.entity.entities.player.windows.ItemContainerWindow;
import com.hypixel.hytale.server.core.inventory.container.ItemContainer;
import com.hypixel.hytale.server.core.inventory.container.SimpleItemContainer;
import com.hypixel.hytale.server.core.inventory.container.SortType;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;

public class StorageBlockWindow extends BlockWindow implements ItemContainerWindow {

    private final SimpleItemContainer itemContainer;
    private final JsonObject windowData = new JsonObject();

    public StorageBlockWindow(int x, int y, int z, int rotationIndex, BlockType blockType, int rows) {
        super(WindowType.Container, x, y, z, rotationIndex, blockType);
        this.itemContainer = new SimpleItemContainer(rows * 9);

        // Initialize window data
        windowData.addProperty("title", "Storage");
        windowData.addProperty("rows", rows);
        windowData.addProperty("blockItemId", blockType.getItem().getId());
    }

    @Override
    public JsonObject getData() {
        return windowData;
    }

    @Override
    public ItemContainer getItemContainer() {
        return itemContainer;
    }

    @Override
    protected boolean onOpen0() {
        // Load items from persistent storage
        loadFromStorage();
        return true;
    }

    @Override
    protected void onClose0() {
        // Save items to persistent storage
        saveToStorage();
    }

    @Override
    public void handleAction(Ref<EntityStore> ref, Store<EntityStore> store, WindowAction action) {
        if (action instanceof SortItemsAction sort) {
            SortType serverSortType = SortType.fromPacket(sort.sortType);
            itemContainer.sort(serverSortType);
            invalidate();
        }
    }

    private void loadFromStorage() {
        // Load from block entity or database
    }

    private void saveToStorage() {
        // Save to block entity or database
    }
}

Usage

@EventHandler
public void onBlockInteract(BlockInteractEvent event) {
    Block block = event.getBlock();

    if (block.getType().getId().equals("my_mod:storage_block")) {
        StorageBlockWindow window = new StorageBlockWindow(
            event.getX(), event.getY(), event.getZ(),
            block.getRotationIndex(),
            block.getType(),
            3 // 3 rows
        );

        Player player = event.getPlayer();
        OpenWindow packet = player.getWindowManager().openWindow(window);

        if (packet != null) {
            event.setCancelled(true);
        }
    }
}

Creating.ui Files for Windows

Basic Page Template

Create a new page UI file in resources/Common/UI/Custom/:

// MyCustomPage.ui
$C = "../Common.ui";

$C.@PageOverlay {}

$C.@Container {
  Anchor: (Width: 500, Height: 400);

  #Title {
    $C.@Title {
      @Text = %server.customUI.myPage.title;
    }
  }

  #Content {
    LayoutMode: Top;
    Padding: (Full: 16);

    // Page content here
    Label #InfoLabel {
      Style: $C.@DefaultLabelStyle;
      Text: "";
    }

    Group {
      Anchor: (Height: 16);  // Spacer
    }

    $C.@TextButton #ConfirmButton {
      @Text = %server.customUI.general.confirm;
    }
  }
}

$C.@BackButton {}

Container with Header and Scrollable Content

$C = "../Common.ui";

$C.@PageOverlay {}

$C.@Container {
  Anchor: (Width: 800, Height: 600);

  #Title {
    Group {
      $C.@Title {
        @Text = %server.customUI.listPage.title;
      }

      $C.@HeaderSearch {}  // Search input on right
    }
  }

  #Content {
    LayoutMode: Left;  // Side-by-side panels

    // Left panel - list
    Group #ListView {
      Anchor: (Width: 250);
      LayoutMode: TopScrolling;
      ScrollbarStyle: $C.@DefaultScrollbarStyle;
    }

    // Right panel - details
    Group #DetailView {
      FlexWeight: 1;
      LayoutMode: Top;
      Padding: (Left: 10);

      Label #ItemName {
        Style: (FontSize: 20, RenderBold: true);
        Anchor: (Bottom: 10);
      }

      Label #ItemDescription {
        Style: (FontSize: 14, TextColor: #96a9be, Wrap: true);
      }
    }
  }
}

$C.@BackButton {}

Reusable List Item Component

Create in resources/Common/UI/Custom/MyListItem.ui:

$C = "../Common.ui";
$Sounds = "../Sounds.ui";

TextButton {
  Anchor: (Bottom: 4, Height: 36);
  Padding: (Horizontal: 12);

  Style: (
    Sounds: $Sounds.@ButtonsLight,
    Default: (
      LabelStyle: (FontSize: 14, VerticalAlignment: Center),
      Background: (Color: #00000000)
    ),
    Hovered: (
      LabelStyle: (FontSize: 14, VerticalAlignment: Center),
      Background: #ffffff(0.1)
    ),
    Pressed: (
      LabelStyle: (FontSize: 14, VerticalAlignment: Center),
      Background: #ffffff(0.15)
    )
  );

  Text: "";  // Set dynamically
}

Grid Layout with Cards

$C = "../Common.ui";

$C.@PageOverlay {}

$C.@DecoratedContainer {
  Anchor: (Width: 900, Height: 650);

  #Title {
    Label {
      Style: $C.@TitleStyle;
      Text: %server.customUI.gridPage.title;
    }
  }

  #Content {
    LayoutMode: Top;

    // Scrollable grid container
    Group #GridContainer {
      FlexWeight: 1;
      LayoutMode: TopScrolling;
      ScrollbarStyle: $C.@DefaultScrollbarStyle;
      Padding: (Full: 8);

      // Cards wrap automatically
      Group #CardGrid {
        LayoutMode: LeftCenterWrap;
      }
    }

    // Footer with actions
    Group #Footer {
      Anchor: (Height: 50);
      LayoutMode: Left;
      Padding: (Top: 10);

      Group { FlexWeight: 1; }  // Spacer

      $C.@SecondaryTextButton #CancelBtn {
        @Anchor = (Width: 120, Right: 10);
        @Text = %client.general.button.cancel;
      }

      $C.@TextButton #ConfirmBtn {
        @Anchor = (Width: 120);
        @Text = %client.general.button.confirm;
      }
    }
  }
}

Card Component

$C = "../Common.ui";
$Sounds = "../Sounds.ui";

Button {
  Anchor: (Width: 140, Height: 160, Right: 8, Bottom: 8);

  Style: (
    Sounds: $Sounds.@ButtonsLight,
    Default: (Background: (TexturePath: "CardBackground.png", Border: 8)),
    Hovered: (Background: (TexturePath: "CardBackgroundHovered.png", Border: 8)),
    Pressed: (Background: (TexturePath: "CardBackgroundPressed.png", Border: 8))
  );

  Group {
    LayoutMode: Top;
    Anchor: (Full: 8);

    // Icon
    Group {
      LayoutMode: Middle;
      Anchor: (Height: 80);

      AssetImage #CardIcon {
        Anchor: (Width: 64, Height: 64);
      }
    }

    // Title
    Label #CardTitle {
      Style: (
        FontSize: 13,
        HorizontalAlignment: Center,
        TextColor: #ffffff,
        Wrap: true
      );
    }

    // Subtitle
    Label #CardSubtitle {
      Style: (
        FontSize: 11,
        HorizontalAlignment: Center,
        TextColor: #7a9cc6
      );
    }
  }
}

HUD Element

Create in resources/Common/UI/Custom/MyHudElement.ui:

Group {
  Anchor: (Top: 20, Left: 20, Width: 200, Height: 40);
  LayoutMode: Left;

  // Background with transparency
  Group #Container {
    Background: #000000(0.4);
    Padding: (Horizontal: 12, Vertical: 8);
    LayoutMode: Left;

    // Icon
    Group {
      Background: "StatusIcon.png";
      Anchor: (Width: 24, Height: 24, Right: 8);
    }

    // Value display
    Label #ValueLabel {
      Style: (
        FontSize: 18,
        VerticalAlignment: Center,
        TextColor: #ffffff
      );
      Text: "0";
    }
  }
}

Input Form

$C = "../Common.ui";

$C.@PageOverlay {}

$C.@Container {
  Anchor: (Width: 400, Height: 350);

  #Title {
    $C.@Title {
      @Text = %server.customUI.formPage.title;
    }
  }

  #Content {
    LayoutMode: Top;
    Padding: (Full: 16);

    // Name field
    Label {
      Text: %server.customUI.formPage.nameLabel;
      Style: $C.@DefaultLabelStyle;
      Anchor: (Bottom: 4);
    }

    $C.@TextField #NameInput {
      PlaceholderText: %server.customUI.formPage.namePlaceholder;
      Anchor: (Bottom: 12);
    }

    // Amount field
    Label {
      Text: %server.customUI.formPage.amountLabel;
      Style: $C.@DefaultLabelStyle;
      Anchor: (Bottom: 4);
    }

    $C.@NumberField #AmountInput {
      @Anchor = (Width: 100);
      Value: 1;
      Format: (MinValue: 1, MaxValue: 64);
      Anchor: (Bottom: 12);
    }

    // Checkbox option
    $C.@CheckBoxWithLabel #EnableOption {
      @Text = %server.customUI.formPage.enableOption;
      @Checked = false;
      Anchor: (Bottom: 20);
    }

    // Submit button
    $C.@TextButton #SubmitButton {
      @Text = %server.customUI.general.submit;
    }
  }
}

$C.@BackButton {}

Custom UI Pages

Custom UI Pages are an alternative to the Window system for displaying server-controlled UI. They provide more flexibility for dynamic content and typed event handling.

When to Use Custom Pages vs Windows

Use Custom Pages WhenUse Windows When
Dynamic list contentInventory/item containers
Forms with text inputsCrafting benches
Search/filter interfacesStorage containers
Dialog/choice screensBlock-tied interactions
Complex multi-step wizardsProcessing/smelting UI

Page Class Hierarchy

CustomUIPage (abstract)
├── BasicCustomUIPage          # Simple static pages
└── InteractiveCustomUIPage<T> # Typed event handling (most common)

Quick Start Example

// 1. Create page class with typed event data
public class MyPage extends InteractiveCustomUIPage<MyPage.EventData> {

    public MyPage(PlayerRef playerRef) {
        super(playerRef, CustomPageLifetime.CanDismiss, EventData.CODEC);
    }

    @Override
    public void build(Ref<EntityStore> ref, UICommandBuilder cmd, UIEventBuilder evt, Store<EntityStore> store) {
        // Load UI file (from resources/Common/UI/Custom/)
        cmd.append("MyPage.ui");

        // Set values
        cmd.set("#TitleLabel.Text", "Welcome!");

        // Bind button click
        evt.addEventBinding(
            CustomUIEventBindingType.Activating,
            "#ConfirmButton",
            EventData.of("Action", "Confirm")
        );
    }

    @Override
    public void handleDataEvent(Ref<EntityStore> ref, Store<EntityStore> store, EventData data) {
        if ("Confirm".equals(data.getAction())) {
            this.close();
        }
    }

    // Event data with codec
    public static class EventData {
        public static final BuilderCodec<EventData> CODEC = BuilderCodec.builder(EventData.class, EventData::new)
            .append(new KeyedCodec<>("Action", Codec.STRING), (e, s) -> e.action = s, e -> e.action)
            .add()
            .build();

        private String action;
        public String getAction() { return action; }
    }
}

// 2. Open from a command (AbstractPlayerCommand has 5 parameters)
@Override
protected void execute(
    @Nonnull CommandContext context,
    @Nonnull Store<EntityStore> store,
    @Nonnull Ref<EntityStore> ref,
    @Nonnull PlayerRef playerRef,
    @Nonnull World world
) {
    world.execute(() -> {
        Player player = store.getComponent(ref, Player.getComponentType());
        player.getPageManager().openCustomPage(ref, store, new MyPage(playerRef));
    });
}

Key Components

UICommandBuilder

Loads UI files and sets property values. All .ui files are in resources/Common/UI/Custom/:

UICommandBuilder cmd = new UICommandBuilder();
cmd.append("MyPage.ui");                            // Load UI file (just filename)
cmd.set("#Label.Text", "Hello");                    // Set text
cmd.set("#Checkbox.Value", true);                   // Set boolean
cmd.clear("#List");                                 // Clear children
cmd.append("#List", "ListItem.ui");                 // Add child (just filename)
UIEventBuilder

Binds UI events to server callbacks:

UIEventBuilder evt = new UIEventBuilder();

// Button click with static data
evt.addEventBinding(
    CustomUIEventBindingType.Activating,
    "#Button",
    EventData.of("Action", "Click")
);

// Input change capturing value (@ prefix = codec key)
evt.addEventBinding(
    CustomUIEventBindingType.ValueChanged,
    "#SearchInput",
    EventData.of("@Query", "#SearchInput.Value")
);
CustomPageLifetime
ValueDescription
CantCloseOnly server can close
CanDismissPlayer can close with ESC
CanDismissOrCloseThroughInteractionESC or world interaction

Dynamic List Pattern

private void buildList(UICommandBuilder cmd, UIEventBuilder evt) {
    cmd.clear("#ItemList");

    for (int i = 0; i < items.size(); i++) {
        String selector = "#ItemList[" + i + "]";
        cmd.append("#ItemList", "ListItem.ui");  // Just filename, not path
        cmd.set(selector + " #Name.Text", items.get(i).getName());
        evt.addEventBinding(
            CustomUIEventBindingType.Activating,
            selector,
            EventData.of("ItemId", items.get(i).getId()),
            false  // Don't lock interface
        );
    }
}

// Update list without full rebuild
public void refreshList() {
    UICommandBuilder cmd = new UICommandBuilder();
    UIEventBuilder evt = new UIEventBuilder();
    buildList(cmd, evt);
    this.sendUpdate(cmd, evt, false);
}

Closing Pages

// From within page
this.close();

// From outside
player.getPageManager().setPage(ref, store, Page.None);

See references/custom-ui-pages.md for complete documentation including:

  • Full class reference for CustomUIPage, InteractiveCustomUIPage, BasicCustomUIPage
  • All UICommandBuilder and UIEventBuilder methods
  • CustomUIEventBindingType enum values
  • BuilderCodec pattern for typed event data
  • Complete working examples

Best Practices

State Management

// Always invalidate after modifications
public void updateValue(String key, Object value) {
    windowData.addProperty(key, value.toString());
    invalidate(); // Mark for next update cycle
}

// For structural changes, use setNeedRebuild
public void rebuildCategories() {
    recalculateCategories();
    setNeedRebuild(); // Client will re-render entire window
    invalidate();
}

Resource Cleanup

@Override
protected void onClose0() {
    // Cancel scheduled tasks
    if (updateTask != null) {
        updateTask.cancel(false);
    }

    // Save state
    saveToDatabase();

    // Return items to player if needed
    returnItemsToPlayer();

    // Unregister event listeners (if manually registered)
}

Thread Safety

Window operations should be on the main server thread:

public void updateFromAsync(Data data) {
    server.getScheduler().runTask(() -> {
        applyData(data);
        invalidate();
    });
}

Progress Update Throttling

For windows with progress bars (like crafting), throttle updates:

private static final float MIN_PROGRESS_CHANGE = 0.05f;
private static final long MIN_UPDATE_INTERVAL_MS = 500L;
private float lastUpdatePercent;
private long lastUpdateTimeMs;

private void checkProgressInvalidate(float percent) {
    if (lastUpdatePercent != percent) {
        long time = System.currentTimeMillis();
        if (percent >= 1.0f ||
            percent < lastUpdatePercent ||
            percent - lastUpdatePercent > MIN_PROGRESS_CHANGE ||
            time - lastUpdateTimeMs > MIN_UPDATE_INTERVAL_MS ||
            lastUpdateTimeMs == 0L) {

            lastUpdatePercent = percent;
            lastUpdateTimeMs = time;
            invalidate();
        }
    }
}

Troubleshooting

Window Not Opening

  1. Check onOpen0() returns true
  2. Verify WindowType is valid
  3. Check for exceptions in initialization
  4. Ensure WindowManager.openWindow() is called on correct thread

Items Not Updating

  1. Call invalidate() after modifications
  2. Verify window implements ItemContainerWindow correctly
  3. Check WindowManager.updateWindows() is being called (usually automatic)
  4. Verify getItemContainer() returns the correct container

Actions Not Received

  1. Ensure handleAction() is implemented
  2. Check action type casting (use instanceof pattern matching)
  3. Verify window ID matches in client packets

Window Closing Unexpectedly

For BlockWindow subclasses:

  1. Check player is within maxDistance (default 7.0)
  2. Verify block still exists at position
  3. Ensure block type hasn't changed

Detailed References

For comprehensive documentation:

  • references/ui-file-syntax.md - Complete.ui file syntax and widget reference
  • references/custom-ui-pages.md - CustomUIPage system, event binding, and typed event handling
  • references/window-types.md - All window types with configuration options
  • references/slot-handling.md - Item containers, sorting, and inventory handling

平台分布

Cursor

30.2%
按下载量换算47

Claude Code

24.42%
按下载量换算38

github-copilot

19.77%
按下载量换算30

mcpjam

11.81%
按下载量换算18

zencoder

7.18%
按下载量换算11

crush

3.33%
按下载量换算5

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

继续浏览同类 Skills