added usage of block_place_delay to timeout

This commit is contained in:
uukelele 2025-04-11 16:29:54 +01:00 committed by GitHub
parent 7c3b06caba
commit c5892c0c40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@ import * as mc from "../../utils/mcdata.js";
import * as world from "./world.js"; import * as world from "./world.js";
import pf from 'mineflayer-pathfinder'; import pf from 'mineflayer-pathfinder';
import Vec3 from 'vec3'; import Vec3 from 'vec3';
import settings from "../../../settings.js";
export function log(bot, message) { export function log(bot, message) {
@ -533,7 +534,7 @@ export async function breakBlockAt(bot, x, y, z) {
let block = bot.blockAt(Vec3(x, y, z)); let block = bot.blockAt(Vec3(x, y, z));
if (block.name !== 'air' && block.name !== 'water' && block.name !== 'lava') { if (block.name !== 'air' && block.name !== 'water' && block.name !== 'lava') {
if (bot.modes.isOn('cheat')) { if (bot.modes.isOn('cheat')) {
await new Promise(resolve => setTimeout(resolve, 10)); await new Promise(resolve => setTimeout(resolve, settings.block_place_delay || 10));
let msg = '/setblock ' + Math.floor(x) + ' ' + Math.floor(y) + ' ' + Math.floor(z) + ' air'; let msg = '/setblock ' + Math.floor(x) + ' ' + Math.floor(y) + ' ' + Math.floor(z) + ' air';
bot.chat(msg); bot.chat(msg);
log(bot, `Used /setblock to break block at ${x}, ${y}, ${z}.`); log(bot, `Used /setblock to break block at ${x}, ${y}, ${z}.`);
@ -630,14 +631,14 @@ export async function placeBlock(bot, blockType, x, y, z, placeOn='bottom', dont
if (blockType.includes('stairs')) { if (blockType.includes('stairs')) {
blockType += `[facing=${face}]`; blockType += `[facing=${face}]`;
} }
await new Promise(resolve => setTimeout(resolve, 10)); await new Promise(resolve => setTimeout(resolve, settings.block_place_delay || 10));
let msg = '/setblock ' + Math.floor(x) + ' ' + Math.floor(y) + ' ' + Math.floor(z) + ' ' + blockType; let msg = '/setblock ' + Math.floor(x) + ' ' + Math.floor(y) + ' ' + Math.floor(z) + ' ' + blockType;
bot.chat(msg); bot.chat(msg);
if (blockType.includes('door')) if (blockType.includes('door'))
await new Promise(resolve => setTimeout(resolve, 10)); await new Promise(resolve => setTimeout(resolve, settings.block_place_delay || 10));
bot.chat('/setblock ' + Math.floor(x) + ' ' + Math.floor(y+1) + ' ' + Math.floor(z) + ' ' + blockType + '[half=upper]'); bot.chat('/setblock ' + Math.floor(x) + ' ' + Math.floor(y+1) + ' ' + Math.floor(z) + ' ' + blockType + '[half=upper]');
if (blockType.includes('bed')) if (blockType.includes('bed'))
await new Promise(resolve => setTimeout(resolve, 10)); await new Promise(resolve => setTimeout(resolve, settings.block_place_delay || 10));
bot.chat('/setblock ' + Math.floor(x) + ' ' + Math.floor(y) + ' ' + Math.floor(z-1) + ' ' + blockType + '[part=head]'); bot.chat('/setblock ' + Math.floor(x) + ' ' + Math.floor(y) + ' ' + Math.floor(z-1) + ' ' + blockType + '[part=head]');
log(bot, `Used /setblock to place ${blockType} at ${target_dest}.`); log(bot, `Used /setblock to place ${blockType} at ${target_dest}.`);
return true; return true;