Skip to content

Commit

Permalink
Create examples/advanced/ (#1768)
Browse files Browse the repository at this point in the history
* Create README.md

* Create chest_confirm.md

* Create accept_texturepack.md
  • Loading branch information
u9g authored Mar 17, 2021
1 parent ef4cc02 commit e7f6c6d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/advanced/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Advanced examples

These are examples that have a very specific use-case, and most people won't need.
14 changes: 14 additions & 0 deletions examples/advanced/accept_texturepack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Accept server's texturepack

This code snippet tells the server that the client accepted a custom texture pack when the server sends a texture pack

```js
bot._client.on('resource_pack_send', (data) => {
bot._client.write('resource_pack_receive', {
result: 3
})
bot._client.write('resource_pack_receive', {
result: 0
})
})
```
14 changes: 14 additions & 0 deletions examples/advanced/chest_confirm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Menual Chest Confirm

This code snippet will tell the bot not to wait for chest confirmations that some spigot plugins will not send

```js
bot.on('windowOpen', async (window) => {
window.requiresConfirmation = false // fix
await bot.clickWindow(13, 0, 0)
console.log(bot._events) // without the fix this code is unreachable, the promise never resolve
})
bot.on('windowClose', () => {
console.log(bot._events) // without the fix there is a confirmTransaction1 listener that is never removed
})
```

0 comments on commit e7f6c6d

Please sign in to comment.