Random Enchanter
The most feature-dense menu in the pack. Combines drag-and-drop slots (the player physically places an item in the menu), the placedItem rule (check what’s in a slot), placeItem action (write into a slot), removePlaced (clear a slot), setButton (replace a static item), and randActions (pick one outcome at random). All of it together gives the player a “throw an item in, gamble for an enchantment” experience.
What it teaches
Section titled “What it teaches”- The
draggable:field with a matrix string defining which slots accept dropped items - The
placedItemrule for checking the contents of a draggable slot - Inverted rules with the
-prefix:-placedItem { ... }means “NOT placed” - The
placeItemaction for writing items into draggable slots removePlacedto clear a draggable slotsetButtonto overwrite a regular menu item dynamically- The
%changed_item_*%placeholder family that captures what the player dragged - Composing
randActionswithplaceItemfor randomized outcomes
How drag-and-drop works
Section titled “How drag-and-drop works”The draggable: field on the menu root takes a matrix of strings, one per row, where x marks a slot players can drop items into. In this example slot 11 (input) and slot 15 (result) are draggable.
draggable: [ "---------", "--x---x--", "---------"]When a slot is draggable, the player can pick items up from their hotbar/inventory and drop them into that slot. The plugin tracks what’s there separately from menu items - drag-and-drop slots are a different overlay on top of the menu grid.
Inside actions, you can:
placedItemrule - check what’s in a draggable slot.placedItem { slot: 11, material: AIR }evaluates true when slot 11 is empty.-placedItem- inverted; same check, opposite result.placeItemaction - write an item into a draggable slot.removePlacedaction - clear a draggable slot.
How the random enchant works
Section titled “How the random enchant works”The enchant button’s click runs three steps:
- Rule check:
-placedItem { slot: 11, material: AIR }- “slot 11 is NOT empty”. If the player hasn’t dropped anything, fall through to denyActions. randActions: pick one entry at random from a list. Each entry callsplaceItemto put a copy of the player’s item (preserved via%changed_item_serialized%) into slot 15, with one of four enchant sets applied.removePlaced: 11: clear the input slot. The original item is gone, the enchanted copy is in slot 15.
The deny path (when input is empty) plays a sound and uses setButton: ${resultStub} to reset the result-slot placeholder back to the gray pane.
Customizing
Section titled “Customizing”To add another enchant outcome, append to the randActions list:
{ placeItem: ${placeItemBase} { enchantments { mending: 1 } } }Each outcome has equal weight by default. For weighted random, repeat outcomes (an item appearing twice in the list is twice as likely to be picked).
Try it
Section titled “Try it”After installing the example pack:
- Drop the bundle into
plugins/AbstractMenus/menus/example/. /am reload.- Type
/ame_enchanterin-game. - Drag a sword/pickaxe into the left slot.
- Click “Enchant!”. The result appears in the right slot with a random enchant.