InventoryAssert for verifying inventory contents by section and slot, and LootAssert for verifying drop lists after entity kills or loot table rolls.
Inventory and loot testing catches bugs that are easy to miss manually - items placed in the wrong slot, stacks that exceed their maximum, loot tables that drop nothing, or equipment that fails to appear in the armor section. Automated tests verify these mechanics consistently across every build.
Item IDs and drop list IDs used in examples depend on the game’s item registry. Replace with your mod’s actual item and drop list identifiers.
Inventory Section Constants
Inventories in Hytale are divided into sections. HRTK defines constants for the three standard sections:
These constants keep your test code readable. Instead of writing magic numbers like
0 or 2, you write InventoryAssert.SECTION_HOTBAR.
Complete Example Suite
InventoryAssert Methods
LootAssert Methods
Inventory Testing Patterns
Inventory tests follow a consistent pattern:- Spawn an NPC that has an inventory component
- Give items using
ctx.giveItem(entity, itemId, count) - Retrieve the inventory with
ctx.getInventory(entity) - Assert on slots, sections, or the whole inventory
- Spawn an NPC, then kill it
- Collect drops using
ctx.awaitCondition(() -> ctx.collectDrops(...), maxTicks) - Assert on the drop list contents
Next Steps
- Effects - status effect assertions
- Stats & Combat - health and damage checks
- Flow Tests - multi-step spawn-kill-loot flows