AgentSkillsCN

hytale-modding

为 Hypixel Studios 的体素沙盒 RPG 游戏《Hytale》开发模组。当您需要创建服务器插件(命令、事件、实体)、运用实体组件系统(ECS)、自定义用户界面、管理物品库存、生成世界地图、制作预制资源,或发布模组时,请使用此技能。本指南涵盖 Java 25 开发环境,包括 Maven 的使用、IntelliJ IDEA 的配置,以及完整的插件开发生命周期。

SKILL.md
--- frontmatter
name: hytale-modding
description: Develop mods for Hytale, a voxel-based sandbox RPG by Hypixel Studios. Use when creating server plugins (commands, events, entities), working with the Entity Component System (ECS), creating custom UI, managing inventory, world generation, prefabs, or publishing mods. Covers Java 25 development with Maven, IntelliJ IDEA setup, and the complete plugin development lifecycle.

Hytale Modding

Quick Start

  1. Setup: Java 25 + IntelliJ IDEA + Maven (see references/dev-environment.md)
  2. Clone template: git clone https://github.com/HytaleModding/plugin-template.git MyMod
  3. Add server JAR: Install HytaleServer.jar to local Maven repo
  4. Build: mvn package produces JAR in target/
  5. Test: Copy JAR to %appdata%/Hytale/UserData/Mods/

Architecture: Entity Component System (ECS)

Hytale uses ECS - understand these core concepts:

ConceptPurposeExample
EntityUnique identifier (no data)Player, Minecart, Block
ComponentData container (no logic)TransformComponent, Health
SystemLogic processorDamageSystem, MovementSystem
StoreEntity managerEntityStore, ChunkStore
HolderBlueprint before spawning"Shopping cart" for components
RefSafe entity referenceNEVER store entity objects directly

See references/ecs.md for complete ECS guide.

Plugin Structure

code
MyMod/
├── pom.xml                 # Maven config
├── manifest.json           # Plugin metadata
├── src/main/java/
│   └── com/example/
│       └── MyPlugin.java   # Main plugin class
└── resources/
    └── Common/UI/Custom/   # UI files (if using custom UI)

Main Plugin Class:

java
public class MyPlugin extends JavaPlugin {
    @Override
    public void setup() {
        // Register commands, events, systems here
    }
}

Common Tasks

Creating Commands

Extend AbstractPlayerCommand:

java
public class MyCommand extends AbstractPlayerCommand {
    public MyCommand() {
        super("mycommand", "Description");
    }

    @Override
    public void execute(CommandContext ctx, Store<EntityStore> store,
                        Ref<EntityStore> ref, PlayerRef player, World world) {
        player.sendMessage(Message.raw("Hello!"));
    }
}

Register in setup(): getCommandRegistry().register(new MyCommand());

Listening to Events

java
public static void onPlayerReady(PlayerReadyEvent event) {
    Player player = event.getPlayer();
    player.sendMessage(Message.raw("Welcome " + player.getDisplayName()));
}

Register: getEventRegistry().registerGlobal(PlayerReadyEvent.class, MyEvents::onPlayerReady);

Spawning Entities

java
world.execute(() -> {
    Holder<EntityStore> holder = EntityStore.REGISTRY.newHolder();
    ModelAsset asset = ModelAsset.getAssetMap().getAsset("Minecart");
    Model model = Model.createScaledModel(asset, 1.0f);

    holder.addComponent(new TransformComponent(position, rotation));
    holder.addComponent(new PersistentModel(model));
    holder.addComponent(new ModelComponent(model));
    // ... add required components

    store.addEntity(holder, AddReason.SPAWN);
});

Playing Sounds

java
int soundIndex = SoundEvent.getAssetMap().getIndex("SFX_Cactus_Large_Hit");
world.execute(() -> {
    SoundUtil.playSoundEvent3dToPlayer(playerRef, soundIndex,
        SoundCategory.UI, transform.getPosition(), store);
});

Reference Documentation

TopicFileContents
Dev Environmentreferences/dev-environment.mdJava 25, IntelliJ, Maven setup
ECS Architecturereferences/ecs.mdStore, Holder, Ref, Components, Systems
Server Pluginsreferences/server-plugins.mdCommands, events, UI, packets
Gameplay Systemsreferences/gameplay-systems.mdEntities, inventory, blocks, prefabs
World Generationreferences/world-generation.mdZones, biomes, caves
Publishingreferences/publishing.mdModtale, CurseForge distribution

Key APIs

Entity Access:

  • player.getWorld() - Get world from player
  • world.getEntityStore().getStore() - Get entity store
  • store.getComponent(ref, componentType) - Get component from entity

Common Components:

  • TransformComponent - Position and rotation
  • PlayerRef / Player - Player connection and presence
  • UUIDComponent - Entity unique ID
  • ModelComponent - Visual model

System Types:

  • EntityTickingSystem - Per-entity each tick
  • TickingSystem - Global each tick
  • DelayedEntitySystem - Per-entity with delay
  • RefChangeSystem - React to component changes

Manifest.json

json
{
    "PluginId": "com.example.myplugin",
    "PluginName": "My Plugin",
    "PluginVersion": "1.0.0",
    "IncludesAssetPack": true
}

Set IncludesAssetPack: true when including custom UI or assets.

Testing Workflow

  1. Build: mvn package
  2. Copy JAR to %appdata%/Hytale/UserData/Mods/
  3. Launch Hytale → Create World → Settings → Mods
  4. Enable "Diagnostic Mode" in settings for error details