diff --git a/doc/api.md b/doc/api.md index 386d81d33..bac8a9a19 100644 --- a/doc/api.md +++ b/doc/api.md @@ -787,7 +787,7 @@ All scoreboards known to the bot in an object scoreboard name -> scoreboard. #### bot.controlState -An object whose keys are the main control states: ['forward', 'back', 'left', 'right', 'jump', 'sprint']. +An object whose keys are the main control states: ['forward', 'back', 'left', 'right', 'jump', 'sprint', 'sneak']. Setting values for this object internally calls [bot.setControlState](#botsetcontrolstatecontrol-state). @@ -1144,7 +1144,7 @@ Get out of bed. `cb` can have an err parameter if the bot cannot wake up. #### bot.setControlState(control, state) - * `control` - one of ['forward', 'back', 'left', 'right', 'jump', 'sprint'] + * `control` - one of ['forward', 'back', 'left', 'right', 'jump', 'sprint', 'sneak'] * `state` - `true` or `false` #### bot.clearControlStates() diff --git a/lib/plugins/physics.js b/lib/plugins/physics.js index 1851da1c1..a547e52cf 100644 --- a/lib/plugins/physics.js +++ b/lib/plugins/physics.js @@ -34,7 +34,8 @@ function inject (bot) { left: false, right: false, jump: false, - sprint: false + sprint: false, + sneak: false } let jumpQueued = false let lastSentYaw = null @@ -302,6 +303,12 @@ function inject (bot) { actionId: state ? 3 : 4, jumpBoost: 0 }) + } else if (control === 'sneak') { + bot._client.write('entity_action', { + entityId: bot.entity.id, + actionId: state ? 0 : 1, + jumpBoost: 0 + }) } }