Inventory Crafting
A workbench-style menu that “crafts” items: the player must hold the recipe ingredients in their inventory, clicking the recipe consumes them and gives back the crafted result. Different mechanism from drag-and-drop slots - this checks the player’s regular inventory.
What it teaches
Section titled “What it teaches”- The
inventoryItemsrule for “does the player have these items” itemRemoveto consume the matching itemsitemAddto give the crafted output- Defining recipes as named blocks at file scope, referenced via
${name}substitution
How it works
Section titled “How it works”Each recipe defines an output (the crafted item) and a requirements list (the ingredients):
helmetRecipe { output { material: LEATHER_HELMET name: "&aHunter's Hat" enchantments { durability: 2 } } requirements: [ { material: LEATHER, count: 5 } ]}The click block references both:
click { rules { inventoryItems: ${helmetRecipe.requirements} } actions { itemRemove: ${helmetRecipe.requirements} itemAdd: ${helmetRecipe.output} ... } denyActions: ${denyNotEnoughItems}}This pattern keeps the recipe data in one place: the rule, the consumption, and the output all reference the same helmetRecipe block. Adding or editing a recipe means editing one block, not three.
Inventory crafting vs drag-and-drop
Section titled “Inventory crafting vs drag-and-drop”Two distinct AbstractMenus patterns for “crafting”:
- Inventory crafting (this example): items stay in the player’s normal inventory. The
inventoryItemsrule looks at the inventory,itemRemovededucts from it. Player never moves items. - Drag-and-drop crafting: the menu has draggable slots. Player physically drags items into them. Uses the
placeItemaction,placedItemrule, and thedraggablefield on items. See the drag-and-drop docs for the alternative pattern.
This snippet uses the inventory-crafting pattern because it composes well with shop-like UIs and doesn’t need a custom slot configuration.
Adding more recipes
Section titled “Adding more recipes”Define a new xxxRecipe block at file scope with output {} and requirements: [...]. Add an item in the items list referencing it the same way the helmet does. Three places get the recipe: the display item, the rule, the actions. Keeping them all ${xxxRecipe.something} means recipes can’t drift out of sync.
Try it
Section titled “Try it”After installing the example pack:
- Drop the bundle into
plugins/AbstractMenus/menus/example/. /am reload.- Get 5 leather in your inventory.
- Type
/ame_craftin-game. - Click the helmet recipe. Leather consumed, hat appears.