Custom Mechanic¶
This mechanism allows you to realize an extremely customizable mechanism without programming
How does it work?¶
This mechanic is for items only and does not work with blocks/furniture.
For that check the clickAction mechanic. The mechanics let you create subsections composed of 3 parts:
- Event: when is this mechanic triggered? e.g. when you right-click on a block
- Conditions: a set of conditions that must be satisfied. e.g. having a permission
- Actions: a set of actions to perform. e.g. send a command or a message
Info
An optional settings called one_usage allows you to imitate the use of an item at 1.
A comprehensive example¶
myitem:
Mechanics:
custom:
test:
one_usage: false
event: "CLICK:right:all"
conditions:
- '#player.hasPermission("example.permission")'
actions:
- "[console] give <player> cooked_beef 1"
In this example, the subsection test defines a custom mechanic triggered when someone right click (on a block or in the air).
If this player has the permission example.permission, the console will perform the give command and replace <player> by the player name.
The item won't be consumed (one_usage: false).
Available events¶
CLICK:click_type:target_type1,¶
INV_CLICK:click_type:context_type2 ¶
DROP3, PICKUP4, BREAK5, EQUIP6, UNEQUIP7, INV_CLICK8, DEATH9, DROP_ALL10¶
Available conditions¶
Permission-Condition¶
Available actions¶
Command-Action¶
This action lets you run a command either from console or as the player
myitem:
Mechanics:
custom:
mycustom:
event: "CLICK:right:all"
actions:
- "[console] minecraft:give <player> minecraft:paper 2"
- "[player] minecraft:give <player> minecraft:paper 2"
Message-Action¶
myitem:
Mechanics:
custom:
mycustom:
event: "CLICK:right:all"
actions:
- "[message] <red>some message <gradient:red:blue>with MiniMessage support"
ActionBar-Action¶
myitem:
Mechanics:
custom:
mycustom:
event: "CLICK:right:all"
actions:
- "[actionbar] <red>some message <gradient:red:blue>with MiniMessage support"
Sound-Action¶
This action lets you play a sound at a location or at a target with customizable values
source - The source of the sound (List of sources)
volume - The volume to play the sound with
pitch - The pitch to play the sound with
self - If the sound sound be played at the Player and not at a location
Followed by the sound-key to play
myitem:
Mechanics:
custom:
mycustom:
event: "CLICK:right:all"
actions:
- "{source=AMBIENT volume=0.1 pitch=1} [sound] namespace:soundkey"
-
Called when you click with the item.
If either of the below is unspecified, it will default to "all" handlingmouse_click_type:
[ right, left, all ]
target_type:[ block, air, all ]↩ -
Called when you click an item in a GUI.
If either of the below is unspecified, it will default to "all" handlingclick_type:
[ right, left, all ]
context_type:[ shift, all ]↩ -
Called when you drop the item. ↩
-
Called when you pick up the item. ↩
-
Called when a player breaks an item. ↩
-
Called when a player equips an item. ↩
-
Called when a player unequips an item. ↩
-
Called when a player clicks an item in an inventory. ↩
-
Called when a player dies and would normally drop the given item. ↩
-
Called when a player drops an item and no longer has any similar items in their inventory. ↩