BlockTestAdapter handles block manipulation, while BlockAssert offers targeted checks for material, state, group, and trigger properties.
Blocks are the building material of Hytale worlds. Every surface, structure, and terrain feature is made of block types. If your mod adds custom blocks, modifies block behavior, or builds structures programmatically, you need tests to verify that blocks have the correct material properties, belong to the right groups, and respond to triggers as expected.
Block type IDs use the asset name without a namespace prefix (e.g.,
Soil_Dirt not hytale:dirt). The exact block names available depend on the game version and installed content packs. Use BlockTestAdapter.blockTypeExists(id) to check if a block type is available before testing with it.Block Type Asset System
Blocks in Hytale are defined as assets identified by their asset name (like"Rock_Sandstone" or "Soil_Dirt"). Each block type has properties defined in its asset file:
- Material - The physical material type (stone, wood, dirt, etc.) which affects tool interactions, sounds, and particle effects
- State - Block state variants (default, powered, open, etc.) that change behavior without changing the block type
- Group - Logical groups the block belongs to (ores, transparent, vegetation, etc.) used for batch queries
- Trigger - Whether the block acts as a trigger block for game logic (pressure plates, tripwires, etc.)
BlockAssert lets you verify all of these properties in your tests.
Complete Example Suite
Adapter Methods
Assertion Methods
BlockAssert vs WorldAssert
UseWorldAssert.assertBlockAt() for simple type-ID checks (is this block stone?). Use BlockAssert when you need material-level, state-level, or group-level detail.
Next Steps
- World Testing - entity spawning and positioning
- Items - test item stacks and durability
- Physics - test entity movement on blocks