Added block name and properties, also hp and food till #85 is done (#114)

This commit is contained in:
Moondarker 2021-03-18 05:22:41 +03:00 committed by GitHub
parent e7d8fc0e64
commit eb08d3720b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -282,6 +282,17 @@ async function connect (options) {
viewer.camera.updateProjectionMatrix()
renderer.setSize(window.innerWidth, window.innerHeight)
})
// TODO: Remove after #85 is done
debugMenu.customEntries.hp = bot.health
debugMenu.customEntries.food = bot.food
debugMenu.customEntries.saturation = bot.foodSaturation
bot.on('health', () => {
debugMenu.customEntries.hp = bot.health
debugMenu.customEntries.food = bot.food
debugMenu.customEntries.saturation = bot.foodSaturation
})
})
}
main()

View file

@ -91,6 +91,12 @@ class DebugMenu extends LitElement {
const minecraftYaw = viewDegToMinecraft(rot[0] * -180 / Math.PI)
const minecraftQuad = Math.floor(((minecraftYaw + 180) / 90 + 0.5) % 4)
const renderProp = (name, value, nextItem) => {
return html`${name}: ${typeof value === 'boolean'
? html`<span style="color: ${value ? 'lightgreen' : 'red'}">${value}</span>`
: value}${nextItem ? ' / ' : ''}`
}
return html`
<div id="debugmenu-wrapper" class="debugmenu-wrapper">
<div class="debugmenu" id="debugmenu">
@ -100,7 +106,8 @@ class DebugMenu extends LitElement {
<p>Chunk: ${Math.floor(pos.x % 16)} ~ ${Math.floor(pos.z % 16)} in ${Math.floor(pos.x / 16)} ~ ${Math.floor(pos.z / 16)}</p>
<p>Facing (viewer): ${rot[0].toFixed(3)} ${rot[1].toFixed(3)}</p>
<p>Facing (minecraft): ${quadsDescription[minecraftQuad]} (${minecraftYaw.toFixed(1)} ${(rot[1] * -180 / Math.PI).toFixed(1)})</p>
${targetDiggable ? html`<p>Looking at: ${target.position.x} ${target.position.y} ${target.position.z}</p>` : ''}<br>
${targetDiggable ? html`<p>Looking at: ${target.position.x} ${target.position.y} ${target.position.z}</p>` : ''}
${targetDiggable ? html`<p>${target.name} | ${Object.entries(target.getProperties()).map(([n, p], idx, arr) => renderProp(n, p, arr[idx + 1]))}</p>` : ''}<br>
${Object.entries(this.customEntries).map(([name, value]) => html`<p>${name}: ${value}</p>`)}
</div>
</div>