mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-22 06:02:07 +02:00
commit
265dd6a076
4 changed files with 34 additions and 9 deletions
17
patches/mineflayer-pathfinder+2.4.5.patch
Normal file
17
patches/mineflayer-pathfinder+2.4.5.patch
Normal file
|
@ -0,0 +1,17 @@
|
|||
diff --git a/node_modules/mineflayer-pathfinder/lib/movements.js b/node_modules/mineflayer-pathfinder/lib/movements.js
|
||||
index a7e3505..77e428f 100644
|
||||
--- a/node_modules/mineflayer-pathfinder/lib/movements.js
|
||||
+++ b/node_modules/mineflayer-pathfinder/lib/movements.js
|
||||
@@ -143,7 +143,11 @@ class Movements {
|
||||
for (const id of this.scafoldingBlocks) {
|
||||
for (const j in items) {
|
||||
const item = items[j]
|
||||
- if (item.type === id) count += item.count
|
||||
+ if (item.type === id) {
|
||||
+ count += item.count
|
||||
+ if (this.bot.game.gameMode === 'creative')
|
||||
+ count = 1000
|
||||
+ }
|
||||
}
|
||||
}
|
||||
return count
|
|
@ -17,10 +17,11 @@ export const queryList = [
|
|||
let pos = bot.entity.position;
|
||||
// display position to 2 decimal places
|
||||
res += `\n- Position: x: ${pos.x.toFixed(2)}, y: ${pos.y.toFixed(2)}, z: ${pos.z.toFixed(2)}`;
|
||||
res += `\n- Gamemode: ${bot.game.gameMode}`;
|
||||
res += `\n- Health: ${Math.round(bot.health)} / 20`;
|
||||
res += `\n- Hunger: ${Math.round(bot.food)} / 20`;
|
||||
res += `\n- Biome: ${world.getBiomeName(bot)}`;
|
||||
let weather = "clear";
|
||||
let weather = "Clear";
|
||||
if (bot.rainState > 0)
|
||||
weather = "Rain";
|
||||
if (bot.thunderState > 0)
|
||||
|
@ -57,9 +58,12 @@ export const queryList = [
|
|||
if (inventory[item] && inventory[item] > 0)
|
||||
res += `\n- ${item}: ${inventory[item]}`;
|
||||
}
|
||||
if (res == 'INVENTORY') {
|
||||
if (res === 'INVENTORY') {
|
||||
res += ': none';
|
||||
}
|
||||
else if (agent.bot.game.gameMode === 'creative') {
|
||||
res += '\n(You have infinite items in creative mode)';
|
||||
}
|
||||
return pad(res);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -463,12 +463,14 @@ export async function breakBlockAt(bot, x, y, z) {
|
|||
bot.pathfinder.setMovements(movements);
|
||||
await bot.pathfinder.goto(new pf.goals.GoalNear(pos.x, pos.y, pos.z, 4));
|
||||
}
|
||||
if (bot.gameMode !== 'creative') {
|
||||
await bot.tool.equipForBlock(block);
|
||||
const itemId = bot.heldItem ? bot.heldItem.type : null
|
||||
if (!block.canHarvest(itemId)) {
|
||||
log(bot, `Don't have right tools to break ${block.name}.`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
await bot.dig(block, true);
|
||||
log(bot, `Broke ${block.name} at x:${x.toFixed(1)}, y:${y.toFixed(1)}, z:${z.toFixed(1)}.`);
|
||||
}
|
||||
|
|
|
@ -26,13 +26,15 @@ const modes = [
|
|||
const bot = agent.bot;
|
||||
const block = bot.blockAt(bot.entity.position);
|
||||
const blockAbove = bot.blockAt(bot.entity.position.offset(0, 1, 0));
|
||||
if (blockAbove && (blockAbove.name === 'water' || blockAbove.name === 'flowing_water')) {
|
||||
if (!block) block = {name: 'air'}; // hacky fix when blocks are not loaded
|
||||
if (!blockAbove) blockAbove = {name: 'air'};
|
||||
if (blockAbove.name === 'water' || blockAbove.name === 'flowing_water') {
|
||||
// does not call execute so does not interrupt other actions
|
||||
if (!bot.pathfinder.goal) {
|
||||
bot.setControlState('jump', true);
|
||||
}
|
||||
}
|
||||
else if (blockAbove && this.fall_blocks.some(name => blockAbove.name.includes(name))) {
|
||||
else if (this.fall_blocks.some(name => blockAbove.name.includes(name))) {
|
||||
execute(this, agent, async () => {
|
||||
await skills.moveAway(bot, 2);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue