import { useVersion } from '../contexts/Version.jsx' import { useAsync } from '../hooks/useAsync.js' import { getEnchantmentData, MaxDamageItems } from '../previews/LootTable.js' import { getTranslation } from '../services/Resources.js' import { TextComponent } from './TextComponent.jsx' interface Props { id: string, tag?: any, advanced?: boolean, offset?: [number, number], swap?: boolean, } export function ItemTooltip({ id, tag, advanced, offset = [0, 0], swap }: Props) { const { version } = useVersion() const { value: translatedName } = useAsync(() => { const key = id.split(':').join('.') return getTranslation(version, `item.${key}`) ?? getTranslation(version, `block.${key}`) }, [version, id]) const displayName = tag?.display?.Name const name = displayName ? JSON.parse(displayName) : (translatedName ?? fakeTranslation(id)) const maxDamage = MaxDamageItems.get(id) return