mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-09 08:45:33 +02:00
little cleanup of environmental awareness
This commit is contained in:
parent
154e75d199
commit
13dbbbefca
2 changed files with 8 additions and 7 deletions
|
@ -17,9 +17,6 @@ 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)}`;
|
||||
// Environmental Awareness
|
||||
res += '\n- ' + world.getSurroundingBlocks(bot).join('\n- ')
|
||||
res += `\n- First Solid Block Above Head: ${world.getFirstBlockAboveHead(bot, null, 32)}`;
|
||||
// Gameplay
|
||||
res += `\n- Gamemode: ${bot.game.gameMode}`;
|
||||
res += `\n- Health: ${Math.round(bot.health)} / 20`;
|
||||
|
@ -35,6 +32,9 @@ export const queryList = [
|
|||
// res += `\n- Artficial light: ${block.skyLight}`;
|
||||
// res += `\n- Sky light: ${block.light}`;
|
||||
// light properties are bugged, they are not accurate
|
||||
res += '\n- ' + world.getSurroundingBlocks(bot).join('\n- ')
|
||||
res += `\n- First Solid Block Above Head: ${world.getFirstBlockAboveHead(bot, null, 32)}`;
|
||||
|
||||
|
||||
if (bot.time.timeOfDay < 6000) {
|
||||
res += '\n- Time: Morning';
|
||||
|
|
|
@ -67,10 +67,9 @@ export function getSurroundingBlocks(bot) {
|
|||
**/
|
||||
// Create a list of block position results that can be unpacked.
|
||||
let res = [];
|
||||
res.push(`Block Above: ${getBlockAtPosition(bot, 0, 2, 0).name}`);
|
||||
res.push(`Block Below: ${getBlockAtPosition(bot, 0, -1, 0).name}`);
|
||||
res.push(`Block at Head: ${getBlockAtPosition(bot, 0, 1, 0).name}`);
|
||||
res.push(`Block at Legs: ${getBlockAtPosition(bot, 0, 0, 0).name}`);
|
||||
res.push(`Block at Head: ${getBlockAtPosition(bot, 0, 1, 0).name}`);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -92,8 +91,8 @@ export function getFirstBlockAboveHead(bot, ignore_types=null, distance=32) {
|
|||
else {
|
||||
if (!Array.isArray(ignore_types))
|
||||
ignore_types = [ignore_types];
|
||||
for(let ingnore_type of ignore_types) {
|
||||
if (mc.getBlockId(ingnore_type)) ignore_blocks.push(ingnore_type);
|
||||
for(let ignore_type of ignore_types) {
|
||||
if (mc.getBlockId(ignore_type)) ignore_blocks.push(ignore_type);
|
||||
}
|
||||
}
|
||||
// The block above, stops when it finds a solid block .
|
||||
|
@ -109,6 +108,8 @@ export function getFirstBlockAboveHead(bot, ignore_types=null, distance=32) {
|
|||
height = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ignore_blocks.includes(block_above.name)) return 'none';
|
||||
|
||||
return `${block_above.name} (${height} blocks up)`;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue