AgentSkillsCN

hytale-blocks

介绍如何在 Hytale 插件中,借助资产包与 JSON 定义,创建自定义方块。适用于创建方块、定义方块 JSON、配置方块纹理与材质、收集方块类型,或搭建方块资产文件夹结构时使用。触发条件:block、create block、custom block、BlockType、block JSON、block definition、block texture、block material、DrawType、Gathering、方块创建、资产包、IncludesAssetPack、方块物品、立方体方块、方块音效、方块粒子。

SKILL.md
--- frontmatter
name: hytale-blocks
description: Documents how to create custom blocks in Hytale plugins using asset packs and JSON definitions. Use when creating blocks, defining block JSON, configuring block textures, materials, gathering, block types, or setting up block asset folder structure. Triggers - block, create block, custom block, BlockType, block JSON, block definition, block texture, block material, DrawType, Gathering, block creation, asset pack, IncludesAssetPack, block item, Cube block, block sound, block particle.

Hytale Custom Blocks

Reference for creating custom blocks in Hytale plugins via asset packs and JSON item definitions with BlockType configuration.

Source: https://hytalemodding.dev/en/docs/guides/plugin/creating-block Related skills: For block components and ECS ticking behavior, see hytale-ecs. For items and interactions, see hytale-items.


Quick Reference

TaskApproach
Enable asset packsSet "IncludesAssetPack": true in manifest.json
Define a blockCreate Server/Item/Items/<name>.json with a BlockType section
Set block texture"Textures": [{ "All": "BlockTextures/<name>.png" }]
Set block material"Material": "Solid" (or Liquid, NonSolid, etc.)
Set draw type"DrawType": "Cube" (or Cross, Slab, etc.)
Add localized nameServer/Languages/en-US/items.lang<name>.name = Display Name
Set gathering/breaking"Gathering": { "Breaking": { "GatherType": "...", "ItemId": "..." } }
Set block icon"Icon": "Icons/ItemsGenerated/<name>.png"

Prerequisites

Enable Asset Packs

Your plugin's manifest.json must declare asset pack inclusion:

json
{
  "IncludesAssetPack": true,
  "dependencies": ["Hytale:EntityModule", "Hytale:BlockModule"]
}

Folder Structure

code
src/main/resources/
├── manifest.json
├── Server/
│   ├── Item/
│   │   └── Items/
│   │       └── my_new_block.json       # Block definition
│   └── Languages/
│       └── en-US/
│           └── items.lang              # Translations
└── Common/
    ├── Icons/                          # Item icons
    ├── Blocks/
    │   └── my_new_block/
    │       └── model.blockymodel       # Block model
    └── BlockTextures/
        └── my_new_block.png            # Block texture

Translations

Create Server/Languages/en-US/items.lang:

code
my_new_block.name = My New Block
my_new_block.description = My Description

The filename items becomes the translation key prefix, so "items.my_new_block.name" resolves to My New Block.


Block JSON Definition

Create Server/Item/Items/my_new_block.json:

json
{
  "TranslationProperties": {
    "Name": "items.my_new_block.name",
    "Description": "items.my_new_block.description"
  },
  "Id": "My_New_Block",
  "MaxStack": 100,
  "Icon": "Icons/ItemsGenerated/my_new_block.png",
  "Categories": [
    "Blocks.Rocks"
  ],
  "PlayerAnimationsId": "Block",
  "Set": "Rock_Stone",
  "BlockType": {
    "Material": "Solid",
    "DrawType": "Cube",
    "Group": "Stone",
    "Flags": {},
    "Gathering": {
      "Breaking": {
        "GatherType": "Rocks",
        "ItemId": "my_new_block"
      }
    },
    "BlockParticleSetId": "Stone",
    "Textures": [
      {
        "All": "BlockTextures/my_new_block.png"
      }
    ],
    "ParticleColor": "#aeae8c",
    "BlockSoundSetId": "Stone",
    "BlockBreakingDecalId": "Breaking_Decals_Rock"
  },
  "ResourceTypes": [
    {
      "Id": "Rock"
    }
  ]
}

BlockType Properties

PropertyDescriptionExamples
MaterialPhysics material type"Solid", "Liquid", "NonSolid"
DrawTypeHow the block is rendered"Cube", "Cross", "Slab"
GroupBlock category group"Stone", "Wood", "Sand"
FlagsAdditional block flags{} (empty object for defaults)
Gathering.Breaking.GatherTypeTool type needed to break"Rocks", "Wood", "Sand"
Gathering.Breaking.ItemIdItem dropped when brokenID string matching the block's Id
BlockParticleSetIdParticle effect when breaking"Stone", "Wood", "Sand"
TexturesArray of texture definitionsSee Texture Configuration below
ParticleColorBreak particle colorHex color string "#aeae8c"
BlockSoundSetIdSound set for interactions"Stone", "Wood", "Sand"
BlockBreakingDecalIdBreaking animation decal"Breaking_Decals_Rock"

Texture Configuration

Textures are defined as an array of objects. Use "All" to apply one texture to all faces, or specify per-face:

json
"Textures": [
  {
    "All": "BlockTextures/my_block.png"
  }
]

Per-face texturing (when supported):

json
"Textures": [
  {
    "Top": "BlockTextures/my_block_top.png",
    "Bottom": "BlockTextures/my_block_bottom.png",
    "Side": "BlockTextures/my_block_side.png"
  }
]

Item Properties (Top-Level)

These properties are standard item fields that the block also uses:

PropertyDescription
TranslationPropertiesName and Description translation keys
IdUnique identifier for the item/block
MaxStackMaximum stack size in inventory
IconPath to inventory icon image
CategoriesArray of category tags (e.g., "Blocks.Rocks")
PlayerAnimationsIdAnimation set when held (e.g., "Block")
SetVisual set grouping (e.g., "Rock_Stone")
ResourceTypesArray of resource type objects with Id field

Edge Cases & Gotchas

  • All referenced files (textures, models, icons) must exist at the specified paths or the block will fail to load
  • The Id field is case-sensitive and must be unique across all items and blocks
  • Translation keys follow the pattern <lang-filename>.<key>.name — the .lang filename is the prefix
  • IncludesAssetPack must be true in manifest — without it, Common/ assets are ignored
  • Block textures go in Common/BlockTextures/, not Common/Textures/
  • The ItemId in Gathering.Breaking should match the block's Id for the block to drop itself when broken
  • Check lib/Server/ for existing block definitions to see all available property values
code