# ClickAction Mechanic

To get started, create a basic [Custom Block](/mechanics/custom-block-mechanics/noteblock-mechanic.md) or [Furniture](/mechanics/furniture-mechanic.md).

Next, under the mechanics section, you can add the default clickAction mechanic under any\
CustomBlock or Furniture-Mechanic

```yaml
myitem:
  Mechanics:      
    furniture/custom_block:
      clickActions:
        - conditions:
            - '#player.hasPermission("test.permission")'
          actions:
            - '[console] say <player> hello <player>!'
```

With this setup, players will only trigger the console command `say hello <player>` action if they have the permission `test.permission`.

If you are not using conditions, you need to place brackets where they would be:

```yaml
myitem:
  Mechanics:
    furniture/custom_block:
      clickActions:
        - conditions: []
          actions:
            - '[console] say <player> hello <player>!'
```

### Conditions

Conditions are VERY configurable. You can use any of the "get" methods for Player or Server.\
A list of all methods you can use can be found on Papers Javadocs

{% embed url="<https://jd.papermc.io/paper/1.21.8/org/bukkit/entity/Player.html>" %}

{% embed url="<https://jd.papermc.io/paper/1.21.8/org/bukkit/Server.html>" %}
TIP! Click "CTRL + F" and search "get" to find valid methods.
{% endembed %}

Additionally, the Spring Documentation is a good resource for understanding how to use condition expressions.

{% embed url="<https://docs.spring.io/spring-framework/docs/3.0.x/reference/expressions.html>" %}

You can also do a negative check by prefixing the condition with `!` . as an example;

```yaml
myitem:
  Mechanics:      
    furniture/custom_block:
      clickActions:
        - conditions:
            - '!#player.hasPermission("test.permission")'
          actions:
            - '[console] say <player> hello <player>!'
```

This will run the action when the player does not have the **test.permission** permission.

#### Condition Examples

`#server.getOnlinePlayers().size() > 10`

`#server.getAllowEnd()`

`#server.getDefaultGameMode()`

`#player.world.name == 'world'`

`#player.hasPermission("test.permission")`

`#player.gamemode.name() == 'ADVENTURE'`

### Actions

`[console] <command>`

`[player] <command>`

`[message] <message>`

`[actionbar] <message>`

`{source=SOURCE volume=VOLUME pitch=PITCH} [sound] <sound name>`

#### Action Examples

`[console] say hello`

`[player] say hello`

`[message] <blue>Hello!`

`[actionbar] <gray>Hello from the actionbar!`

`{source=AMBIENT volume=0.1 pitch=1} [sound] minecraft:block.shulker_box.close`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nexomc.com/mechanics/clickaction-mechanic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
