From 8983dce5fc50167dfbad6f7cef9179b8fa25c28e Mon Sep 17 00:00:00 2001 From: obseletecode72 <138137862+obseletecode72@users.noreply.github.com> Date: Thu, 7 Mar 2024 19:55:48 -0300 Subject: [PATCH 1/3] Some updates on example.js fix of bot trying to place a block and failing --- examples/example.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/examples/example.js b/examples/example.js index 598d75d..0be9ae6 100644 --- a/examples/example.js +++ b/examples/example.js @@ -75,6 +75,35 @@ bot.once("spawn", async () => { bot.loadPlugin(pathfinder); bot.loadPlugin(loader); +/* miningStates[bot.username] = setInterval(async () => { // if the blockupdate doesnt work this can be an alternative too + try { + if (bot.pathfinder.isBuilding()) { + const blockInHand = bot.heldItem; + + if (blockInHand) { + const lookAtBlockPos = bot.blockAtCursor(); + if (lookAtBlockPos && lookAtBlockPos.position) { + const blockPosStr = lookAtBlockPos.position.toString(); + if (!placedBlocks.has(blockPosStr)) { + await bot.placeBlock(bot.blockAt(lookAtBlockPos.position), new Vec3(0, 1, 0)).catch(); + placedBlocks.add(blockPosStr); + } + } + } + } + } catch (e) { } + }, 100);*/ + + bot.on('blockUpdate', (oldBlock, newBlock) => { // fix for bot failing on trying to place blocks + if (newBlock && !oldBlock) { + placedBlocks.add(newBlock.position.toString()); + //mineBlocks(bot, blockType, newBlock); + } + else if (!newBlock && oldBlock) { + placedBlocks.delete(oldBlock.position.toString()); + } + }); + bot.pathfinder.setPathfinderOptions({ partialPathProducer: true, partialPathLength: 30 From 6289df96a56a4e8041d4c0f5d558e6f9feb13e8f Mon Sep 17 00:00:00 2001 From: obseletecode72 <138137862+obseletecode72@users.noreply.github.com> Date: Thu, 7 Mar 2024 19:56:41 -0300 Subject: [PATCH 2/3] Update example.js --- examples/example.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/example.js b/examples/example.js index 0be9ae6..866cccd 100644 --- a/examples/example.js +++ b/examples/example.js @@ -94,6 +94,8 @@ bot.once("spawn", async () => { } catch (e) { } }, 100);*/ + let placedBlocks = new Set(); + bot.on('blockUpdate', (oldBlock, newBlock) => { // fix for bot failing on trying to place blocks if (newBlock && !oldBlock) { placedBlocks.add(newBlock.position.toString()); From c9b89f1053974b2de433fb3789156cbde06a5e19 Mon Sep 17 00:00:00 2001 From: obseletecode72 <138137862+obseletecode72@users.noreply.github.com> Date: Thu, 7 Mar 2024 19:57:31 -0300 Subject: [PATCH 3/3] Update example.js --- examples/example.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example.js b/examples/example.js index 866cccd..368b990 100644 --- a/examples/example.js +++ b/examples/example.js @@ -75,7 +75,7 @@ bot.once("spawn", async () => { bot.loadPlugin(pathfinder); bot.loadPlugin(loader); -/* miningStates[bot.username] = setInterval(async () => { // if the blockupdate doesnt work this can be an alternative too +/* miningStates[bot.username] = setInterval(async () => { // if the blockupdate event dont work this can be an alternative too try { if (bot.pathfinder.isBuilding()) { const blockInHand = bot.heldItem;