From f1654868139b54869072a7ba2efcbfb1372bc0d3 Mon Sep 17 00:00:00 2001 From: Matej Baco Date: Sat, 4 Nov 2017 12:38:20 +0100 Subject: [PATCH 1/2] Added sneaking option to controll states --- doc/api.md | 4 ++-- lib/plugins/physics.js | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) 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..b0893d767 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 + }) } } From de9eee55582cc7a3521d8d5a631767e9b1f95fd4 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sun, 5 Nov 2017 15:30:36 +0100 Subject: [PATCH 2/2] remove trailing comma --- lib/plugins/physics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/physics.js b/lib/plugins/physics.js index b0893d767..a547e52cf 100644 --- a/lib/plugins/physics.js +++ b/lib/plugins/physics.js @@ -35,7 +35,7 @@ function inject (bot) { right: false, jump: false, sprint: false, - sneak: false, + sneak: false } let jumpQueued = false let lastSentYaw = null