import React, { useState } from 'react'; import { getItemEmoji } from '../utils/itemUtils'; import './ItemIcon.css'; /** * Renders a Minecraft item icon. * First tries to load the actual item sprite from mc-heads.net. * Falls back to an emoji representation if the image fails. */ function ItemIcon({ itemName, size = 32 }) { const [imgError, setImgError] = useState(false); if (!itemName) { return 📦; } // Strip namespace for the icon URL const shortName = itemName.replace(/^[a-z0-9_]+:/, ''); if (imgError) { return ( {getItemEmoji(itemName)} ); } return ( {shortName} setImgError(true)} style={{ imageRendering: 'pixelated' }} /> ); } export default ItemIcon;