Add SQLite persistence + official Minecraft item icons
Database (better-sqlite3): - Persist items, furnaces, alerts, recipes, settings to SQLite - Auto-restore last known state when server restarts or bridge disconnects - Item count history tracking (5-min snapshots, 7-day retention) - /api/history/:itemName endpoint for item count history - Docker volume for database file persistence - Graceful shutdown with DB connection cleanup Icons: - Replace mc-heads.net with official Minecraft game textures via CDN - Cascading fallback: item texture -> block texture -> emoji - In-memory URL cache to avoid redundant network requests - Block texture suffix mapping (furnace_front, barrel_top, etc.) - Crisp pixel-art rendering with image-rendering: pixelated
This commit is contained in:
@@ -1,27 +1,17 @@
|
||||
/**
|
||||
* Minecraft item icon utility
|
||||
* Uses mc-heads.net item renders for actual Minecraft item icons
|
||||
* Minecraft item utility functions
|
||||
* Icons use official game textures via ItemIcon component
|
||||
*/
|
||||
|
||||
// Format an item name for display
|
||||
export function formatItemName(name) {
|
||||
if (!name) return '';
|
||||
return name
|
||||
.replace(/^[a-z0-9_]+:/, '') // Strip mod prefix
|
||||
.replace(/^[a-z0-9_.-]+:/, '') // Strip mod prefix
|
||||
.replace(/_/g, ' ')
|
||||
.replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
}
|
||||
|
||||
// Get icon URL for a Minecraft item
|
||||
// Uses mc-heads.net which provides 2D item renders
|
||||
export function getItemIconUrl(itemName, size = 32) {
|
||||
if (!itemName) return null;
|
||||
// mc-heads.net format: https://mc-heads.net/item/{item_name}
|
||||
// Alternatively we can use crafatar or other MC icon APIs
|
||||
// For items, we use a simple mapping approach
|
||||
return `https://mc-heads.net/item/${itemName}/${size}`;
|
||||
}
|
||||
|
||||
// Fallback emoji mapping for common item categories
|
||||
const CATEGORY_EMOJI = {
|
||||
ingot: '🪙',
|
||||
|
||||
Reference in New Issue
Block a user