This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
ScriptCraft/docs/tutorials/EVENT.md

25 lines
741 B
Markdown
Raw Normal View History

2020-06-02 20:01:26 +00:00
# Use An Event
## Example
```javascript
import { Events } from 'minecraft';
Events.WORLD_TICK.addListener(e => {
// Use e.getWorld()
});
```
## All Events
| Name | Description | Input Type | Output Type |
| --- | --- | --- | --- |
| ```WORLD_TICK``` | Triggered on every world tick. | ```WorldEvent``` | None |
| ```ATTACK_BLOCK``` | Triggered when breaking a block. | ```BlockEvent``` | ```ActionResult``` |
| ```USE_BLOCK``` | Triggered when using a block. | ```BlockEvent``` | ```ActionResult``` |
| ```USE_ITEM``` | Triggered when using an item. | ```ItemEvent``` | ```ActionResult``` |
## Manually Trigger An Event
```javascript
import { Events } from 'minecraft';
const result = Events.<Event Name>.trigger(<Input Value>);
```