Track protocol 777 health and hunger
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
<div class="stat-top"><span class="stat-label">HUNGER</span><span class="stat-icon food">◆</span></div>
|
||||
<div class="stat-value"><span id="food-value">—</span><small>/ 20</small></div>
|
||||
<div class="meter"><span id="food-meter" class="meter-fill food-fill"></span></div>
|
||||
<div id="food-saturation" class="stat-caption">Saturation —</div>
|
||||
</article>
|
||||
<article class="stat-card panel">
|
||||
<div class="stat-top"><span class="stat-label">MOVEMENT</span><span class="live-dot"></span></div>
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<div class="stat-top"><span class="stat-label">HUNGER</span><span class="stat-icon food">◆</span></div>
|
||||
<div class="stat-value"><span id="food-value">—</span><small>/ 20</small></div>
|
||||
<div class="meter"><span id="food-meter" class="meter-fill food-fill"></span></div>
|
||||
<div id="food-saturation" class="stat-caption">Saturation —</div>
|
||||
</article>
|
||||
<article class="stat-card panel">
|
||||
<div class="stat-top"><span class="stat-label">MOVEMENT</span><span class="live-dot"></span></div>
|
||||
|
||||
@@ -147,12 +147,17 @@
|
||||
$('position').textContent = vectorText(state.pos || state.player_position);
|
||||
$('dimension').textContent = dimensionName(state.dimension);
|
||||
|
||||
const health = Number(state.health);
|
||||
const food = Number(state.food);
|
||||
$('health-value').textContent = Number.isFinite(health) ? String(health) : '—';
|
||||
const health = state.health == null ? NaN : Number(state.health);
|
||||
const food = state.food == null ? NaN : Number(state.food);
|
||||
const saturation = state.food_saturation == null
|
||||
? NaN : Number(state.food_saturation);
|
||||
$('health-value').textContent = Number.isFinite(health)
|
||||
? Number(health.toFixed(1)).toString() : '—';
|
||||
$('food-value').textContent = Number.isFinite(food) ? String(food) : '—';
|
||||
$('health-meter').style.width = `${Math.max(0, Math.min(100, health * 5 || 0))}%`;
|
||||
$('food-meter').style.width = `${Math.max(0, Math.min(100, food * 5 || 0))}%`;
|
||||
$('food-saturation').textContent = Number.isFinite(saturation)
|
||||
? `Saturation ${saturation.toFixed(2)}` : 'Saturation —';
|
||||
$('health-meter').style.width = `${Math.max(0, Math.min(100, (health || 0) * 5))}%`;
|
||||
$('food-meter').style.width = `${Math.max(0, Math.min(100, (food || 0) * 5))}%`;
|
||||
|
||||
const movement = state.movement_status || (state.path?.length ? 'following_path' : 'idle');
|
||||
$('movement-value').textContent = String(movement).replaceAll('_', ' ').toUpperCase();
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<div class="stat-top"><span class="stat-label">HUNGER</span><span class="stat-icon food">◆</span></div>
|
||||
<div class="stat-value"><span id="food-value">—</span><small>/ 20</small></div>
|
||||
<div class="meter"><span id="food-meter" class="meter-fill food-fill"></span></div>
|
||||
<div id="food-saturation" class="stat-caption">Saturation —</div>
|
||||
</article>
|
||||
<article class="stat-card panel">
|
||||
<div class="stat-top"><span class="stat-label">MOVEMENT</span><span class="live-dot"></span></div>
|
||||
|
||||
Reference in New Issue
Block a user