Fixed crash on useItem and placeBlock

This commit is contained in:
bit_knox 2019-01-08 16:24:21 +01:00
parent cd3be43a4d
commit 17218a5d79
2 changed files with 2 additions and 0 deletions

View file

@ -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]

View file

@ -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)