The Items surface provides tools for creating and inspecting item stacks outside of an inventory context.Documentation Index
Fetch the complete documentation index at: https://docs.hrtk.frotty27.com/llms.txt
Use this file to discover all available pages before exploring further.
ItemTestAdapter lets you build stacks and read their properties, while ItemAssert covers durability, metadata, and stackability checks.
Item testing ensures that your mod’s items have the correct properties at creation time, that durability degrades and breaks as expected, that stackability rules are enforced, and that custom metadata is preserved. These are the kind of subtle bugs that slip through manual testing - an item that should not stack suddenly stacking, or a tool that starts with zero durability instead of max.
ItemStack Immutability
An important concept to understand: item stacks created withctx.createStack(...) are standalone snapshot objects. They are not placed in any inventory, and modifying the stack does not affect any inventory slot. If you need to test item behavior inside an inventory, use the Inventory & Loot surface instead.
When you read a stack’s properties (ID, size, durability), you are reading the values at the time of creation. If the game engine modifies the underlying item type later, the stack object you hold may not reflect those changes.
Complete Example Suite
Adapter Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
createStack | String itemId, int count | Object | Create an item stack with the given ID and count |
getItemId | Object stack | String | Get the item type ID of the stack |
getStackSize | Object stack | int | Get the current stack count |
getDurability | Object stack | int | Get current durability value |
getMaxDurability | Object stack | int | Get maximum durability value |
isBroken | Object stack | boolean | Check if the item has zero durability |
isStackable | Object stack | boolean | Check if the item type supports stacking |
getMetadata | Object stack, String key | Object | Read a metadata entry from the stack |
setMetadata | Object stack, String key, Object value | void | Write a metadata entry to the stack |
Assertion Methods
| Method | Parameters | Failure Message |
|---|---|---|
assertItemId | Object stack, String expected | ”Expected item ID [expected] but was [actual]“ |
assertStackSize | Object stack, int expected | ”Expected stack size [expected] but was [actual]“ |
assertDurability | Object stack, int expected | ”Expected durability [expected] but was [actual]“ |
assertMaxDurability | Object stack, int expected | ”Expected max durability [expected] but was [actual]“ |
assertBroken | Object stack | ”Expected item to be broken” |
assertNotBroken | Object stack | ”Expected item to not be broken” |
assertStackable | Object stack | ”Expected item to be stackable” |
assertNotStackable | Object stack | ”Expected item to not be stackable” |
assertHasMetadata | Object stack, String key | ”Expected item to have metadata key [key]“ |
When to Test Items
Item tests are most valuable when:- Your mod defines custom items with specific durability values
- You need to verify stackability rules for new item types
- Your items carry custom metadata (enchantments, upgrades, custom properties)
- You want regression tests to catch changes in item type definitions after server updates
Next Steps
- Inventory & Loot - test items inside inventories
- Blocks - test block types and placement
- Stats & Combat - test weapon damage with combat assertions