From 17218a5d7916f659f9dd6b8b2c6630eedf4598b3 Mon Sep 17 00:00:00 2001 From: bit_knox Date: Tue, 8 Jan 2019 16:24:21 +0100 Subject: [PATCH 1/2] Fixed crash on useItem and placeBlock --- src/lib/plugins/placeBlock.js | 1 + src/lib/plugins/useItem.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/lib/plugins/placeBlock.js b/src/lib/plugins/placeBlock.js index 691bc85..2f62d4e 100644 --- a/src/lib/plugins/placeBlock.js +++ b/src/lib/plugins/placeBlock.js @@ -15,6 +15,7 @@ module.exports.player = function (player, serv, { version }) { player._client.on('block_place', ({ direction, location } = {}) => { const heldItem = player.inventory.slots[36 + player.heldItemSlot] + if(heldItem == undefined) return if (direction === -1 || heldItem.type === -1 || !blocks[heldItem.type]) return const referencePosition = new Vec3(location.x, location.y, location.z) const directionVector = directionToVector[direction] diff --git a/src/lib/plugins/useItem.js b/src/lib/plugins/useItem.js index d327674..82f5f30 100644 --- a/src/lib/plugins/useItem.js +++ b/src/lib/plugins/useItem.js @@ -5,6 +5,7 @@ module.exports.player = function (player, serv, { version }) { player._client.on('block_place', ({ direction, location } = {}) => { const heldItem = player.inventory.slots[36 + player.heldItemSlot] + if(heldItem == undefined) return if (direction === -1 || heldItem.type === -1 || !items[heldItem.type]) return const item = heldItem const referencePosition = new Vec3(location.x, location.y, location.z) From 4772c683b77c0b38a6d0a5317ab86378366a6291 Mon Sep 17 00:00:00 2001 From: bit_knox Date: Wed, 9 Jan 2019 01:24:55 +0000 Subject: [PATCH 2/2] Fixed style to fit JavaScript Standard --- src/lib/plugins/placeBlock.js | 2 +- src/lib/plugins/useItem.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/plugins/placeBlock.js b/src/lib/plugins/placeBlock.js index 2f62d4e..cac40fc 100644 --- a/src/lib/plugins/placeBlock.js +++ b/src/lib/plugins/placeBlock.js @@ -15,7 +15,7 @@ module.exports.player = function (player, serv, { version }) { player._client.on('block_place', ({ direction, location } = {}) => { const heldItem = player.inventory.slots[36 + player.heldItemSlot] - if(heldItem == undefined) return + if (heldItem === undefined) return if (direction === -1 || heldItem.type === -1 || !blocks[heldItem.type]) return const referencePosition = new Vec3(location.x, location.y, location.z) const directionVector = directionToVector[direction] diff --git a/src/lib/plugins/useItem.js b/src/lib/plugins/useItem.js index 82f5f30..bfcdfef 100644 --- a/src/lib/plugins/useItem.js +++ b/src/lib/plugins/useItem.js @@ -5,7 +5,7 @@ module.exports.player = function (player, serv, { version }) { player._client.on('block_place', ({ direction, location } = {}) => { const heldItem = player.inventory.slots[36 + player.heldItemSlot] - if(heldItem == undefined) return + if (heldItem === undefined) return if (direction === -1 || heldItem.type === -1 || !items[heldItem.type]) return const item = heldItem const referencePosition = new Vec3(location.x, location.y, location.z)