mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-26 00:16:51 +00:00
Fix not correctly enchanting books
This commit is contained in:
@@ -21,6 +21,7 @@ export function ItemTooltip({ id, tag, advanced, offset = [0, 0], swap }: Props)
|
||||
const name = displayName ? JSON.parse(displayName) : (translatedName ?? fakeTranslation(id))
|
||||
|
||||
const maxDamage = MaxDamageItems.get(id)
|
||||
const enchantments = (id === 'minecraft:enchanted_book' ? tag?.StoredEnchantments : tag?.Enchantments) ?? []
|
||||
|
||||
return <div class="item-tooltip" style={offset && {
|
||||
left: (swap ? undefined : `${offset[0]}px`),
|
||||
@@ -28,7 +29,7 @@ export function ItemTooltip({ id, tag, advanced, offset = [0, 0], swap }: Props)
|
||||
top: `${offset[1]}px`,
|
||||
}}>
|
||||
<TextComponent component={name} base={{ color: 'white' }} />
|
||||
{tag?.Enchantments?.map(({ id, lvl }: { id: string, lvl: number }) => {
|
||||
{enchantments.map(({ id, lvl }: { id: string, lvl: number }) => {
|
||||
const ench = getEnchantmentData(id)
|
||||
const component: any[] = [{ translate: `enchantment.${id.replace(':', '.')}`, color: ench?.curse ? 'red' : 'gray' }]
|
||||
if (lvl !== 1 || ench?.maxLevel !== 1) {
|
||||
|
||||
@@ -25,6 +25,7 @@ export const LootTablePreview = ({ data }: PreviewProps) => {
|
||||
const state = JSON.stringify(table)
|
||||
useEffect(() => {
|
||||
const items = generateLootTable(table, { version, seed, luck, daytime, weather, stackMixer: mixItems ? 'container' : 'default' })
|
||||
console.log('Generated loot', items)
|
||||
setItems(items)
|
||||
}, [version, seed, luck, daytime, weather, mixItems, state])
|
||||
|
||||
|
||||
@@ -271,22 +271,33 @@ const LootFunctions: Record<string, (params: any) => LootFunction> = {
|
||||
return data.discoverable && (isBook || data.canEnchant(item.id))
|
||||
})
|
||||
}
|
||||
const id = enchantments[ctx.random.nextInt(enchantments.length)]
|
||||
const data = getEnchantmentData(id)
|
||||
const lvl = ctx.random.nextInt(data.maxLevel - data.minLevel + 1) + data.minLevel
|
||||
enchantItem(item, { id, lvl })
|
||||
if (enchantments.length > 0) {
|
||||
const id = enchantments[ctx.random.nextInt(enchantments.length)]
|
||||
const data = getEnchantmentData(id)
|
||||
const lvl = ctx.random.nextInt(data.maxLevel - data.minLevel + 1) + data.minLevel
|
||||
if (isBook) {
|
||||
item.tag = {}
|
||||
item.count = 1
|
||||
}
|
||||
enchantItem(item, { id, lvl })
|
||||
if (isBook) {
|
||||
item.id = 'minecraft:enchanted_book'
|
||||
}
|
||||
}
|
||||
},
|
||||
enchant_with_levels: ({ levels, treasure }) => (item, ctx) => {
|
||||
const enchants = selectEnchantments(ctx.random, item, computeInt(levels, ctx), treasure)
|
||||
const isBook = item.id === 'minecraft:book'
|
||||
if (isBook) {
|
||||
item.id = 'minecraft:enchanted_book'
|
||||
item.count = 1
|
||||
item.tag = {}
|
||||
}
|
||||
for (const enchant of enchants) {
|
||||
enchantItem(item, enchant)
|
||||
}
|
||||
if (isBook) {
|
||||
item.id = 'minecraft:enchanted_book'
|
||||
}
|
||||
},
|
||||
limit_count: ({ limit }) => (item, ctx) => {
|
||||
const { min, max } = prepareIntRange(limit, ctx)
|
||||
|
||||
@@ -1238,7 +1238,7 @@ hr {
|
||||
.item-display > .item-glint,
|
||||
.item-display > .item-glint::after {
|
||||
background: url(/images/glint.png) repeat;
|
||||
filter: brightness(1.4) blur(1px) opacity(0.8);
|
||||
filter: brightness(1.6) blur(1px) opacity(0.7);
|
||||
animation: glint 20s linear 0s infinite;
|
||||
background-size: 400%;
|
||||
background-blend-mode: overlay;
|
||||
|
||||
Reference in New Issue
Block a user