diff --git a/package-lock.json b/package-lock.json index 38489487..b98d55dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "brace": "^0.11.1", "buffer": "^6.0.3", "comment-json": "^4.1.1", - "deepslate": "^0.15.5", + "deepslate": "^0.15.6", "deepslate-1.18": "npm:deepslate@^0.9.0-beta.9", "deepslate-1.18.2": "npm:deepslate@^0.9.0-beta.13", "highlight.js": "^11.5.1", @@ -1955,9 +1955,9 @@ "dev": true }, "node_modules/deepslate": { - "version": "0.15.5", - "resolved": "https://registry.npmjs.org/deepslate/-/deepslate-0.15.5.tgz", - "integrity": "sha512-t+ucG50ldN0HMiDfXk8Tpzpw2ld6BA6NxJClQV+sB429vn1YmTk6WZx8GXd1exgUf/XYNR+ax+cxv/9Zr6Qy3g==", + "version": "0.15.6", + "resolved": "https://registry.npmjs.org/deepslate/-/deepslate-0.15.6.tgz", + "integrity": "sha512-aUNkqozUTvEuR/tFWCiFCpsJ4Q8AaHyvHY33/T7K+cUY9V6wlrlUwPCgwoaP3G6AMWUm5vN57NSu+dC8ESTDww==", "dependencies": { "gl-matrix": "^3.3.0", "md5": "^2.3.0", @@ -6698,9 +6698,9 @@ "dev": true }, "deepslate": { - "version": "0.15.5", - "resolved": "https://registry.npmjs.org/deepslate/-/deepslate-0.15.5.tgz", - "integrity": "sha512-t+ucG50ldN0HMiDfXk8Tpzpw2ld6BA6NxJClQV+sB429vn1YmTk6WZx8GXd1exgUf/XYNR+ax+cxv/9Zr6Qy3g==", + "version": "0.15.6", + "resolved": "https://registry.npmjs.org/deepslate/-/deepslate-0.15.6.tgz", + "integrity": "sha512-aUNkqozUTvEuR/tFWCiFCpsJ4Q8AaHyvHY33/T7K+cUY9V6wlrlUwPCgwoaP3G6AMWUm5vN57NSu+dC8ESTDww==", "requires": { "gl-matrix": "^3.3.0", "md5": "^2.3.0", diff --git a/package.json b/package.json index 46ec824a..9b0b276a 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "brace": "^0.11.1", "buffer": "^6.0.3", "comment-json": "^4.1.1", - "deepslate": "^0.15.5", + "deepslate": "^0.15.6", "deepslate-1.18": "npm:deepslate@^0.9.0-beta.9", "deepslate-1.18.2": "npm:deepslate@^0.9.0-beta.13", "highlight.js": "^11.5.1", diff --git a/src/app/components/ItemTooltip.tsx b/src/app/components/ItemTooltip.tsx index 6391757e..7c813ab9 100644 --- a/src/app/components/ItemTooltip.tsx +++ b/src/app/components/ItemTooltip.tsx @@ -1,5 +1,5 @@ import type { ItemStack } from 'deepslate' -import { Identifier, NbtList, NbtType } from 'deepslate' +import { NbtList, NbtType } from 'deepslate' import { useVersion } from '../contexts/Version.jsx' import { useAsync } from '../hooks/useAsync.js' import { getEnchantmentData, MaxDamageItems } from '../previews/LootTable.js' @@ -22,7 +22,7 @@ export function ItemTooltip({ item, advanced, offset = [0, 0], swap }: Props) { const name = displayName ? JSON.parse(displayName) : (translatedName ?? fakeTranslation(item.id.path)) const maxDamage = MaxDamageItems.get(item.id.toString()) - const enchantments = (item.id.equals(Identifier.create('enchanted_book')) ? item.tag.getList('StoredEnchantments', NbtType.Compound) : item.tag.getList('Enchantments', NbtType.Compound)) ?? NbtList.create() + const enchantments = (item.is('enchanted_book') ? item.tag.getList('StoredEnchantments', NbtType.Compound) : item.tag.getList('Enchantments', NbtType.Compound)) ?? NbtList.create() return
i), ctx) - const queue = items.filter(i => !i.id.equals(Identifier.create('air')) && i.count > 1) - items = items.filter(i => !i.id.equals(Identifier.create('air')) && i.count === 1) + const queue = items.filter(i => !i.is('air') && i.count > 1) + items = items.filter(i => !i.is('air') && i.count === 1) while (SLOT_COUNT - items.length - queue.length > 0 && queue.length > 0) { const [itemA] = queue.splice(ctx.random.nextInt(queue.length), 1) @@ -75,7 +75,7 @@ function fillContainer(items: ItemStack[], ctx: LootContext): SlottedItem[] { if (slot === undefined) { break } - if (!item.id.equals(Identifier.create('air')) && item.count > 0) { + if (!item.is('air') && item.count > 0) { results.push({ slot, item }) } } @@ -89,7 +89,7 @@ function assignSlots(items: ItemStack[]): SlottedItem[] { if (slot >= 27) { break } - if (!item.id.equals(Identifier.create('air')) && item.count > 0) { + if (!item.is('air') && item.count > 0) { results.push({ slot, item }) slot += 1 } @@ -99,7 +99,7 @@ function assignSlots(items: ItemStack[]): SlottedItem[] { function splitItem(item: ItemStack, count: number): ItemStack { const splitCount = Math.min(count, item.count) - const other = deepClone(item) + const other = item.clone() other.count = splitCount item.count = item.count - splitCount return other @@ -271,7 +271,7 @@ function composeFunctions(functions: any[]): LootFunction { const LootFunctions: Record LootFunction> = { enchant_randomly: ({ enchantments }) => (item, ctx) => { - const isBook = item.id.equals(Identifier.create('book')) + const isBook = item.is('book') if (enchantments === undefined || enchantments.length === 0) { enchantments = [...Enchantments.keys()] .filter(e => { @@ -295,7 +295,7 @@ const LootFunctions: Record LootFunction> = { }, enchant_with_levels: ({ levels, treasure }) => (item, ctx) => { const enchants = selectEnchantments(ctx.random, item, computeInt(levels, ctx), treasure) - const isBook = item.id.equals(Identifier.create('book')) + const isBook = item.is('book') if (isBook) { item.count = 1 item.tag = new NbtCompound() @@ -308,7 +308,7 @@ const LootFunctions: Record LootFunction> = { } }, exploration_map: ({ decoration }) => (item) => { - if (!item.id.equals(Identifier.create('map'))) { + if (!item.is('map')) { return } item.id = Identifier.create('filled_map') @@ -532,7 +532,7 @@ function testDamageSourcePredicate(_predicate: any, _ctx: LootContext) { } function enchantItem(item: ItemStack, enchant: Enchant, additive?: boolean) { - const listKey = item.id.equals(Identifier.create('book')) ? 'StoredEnchantments' : 'Enchantments' + const listKey = item.is('book') ? 'StoredEnchantments' : 'Enchantments' if (!item.tag.hasList(listKey, NbtType.Compound)) { item.tag.set(listKey, new NbtList()) } @@ -587,7 +587,7 @@ function getEnchantWeight(ench: Enchant) { function getAvailableEnchantments(item: ItemStack, levels: number, treasure: boolean): Enchant[] { const result = [] - const isBook = item.id.equals(Identifier.create('book')) + const isBook = item.is('book') for (const id of Enchantments.keys()) { const ench = getEnchantmentData(id)! @@ -1044,10 +1044,10 @@ export function itemHasGlint(item: ItemStack) { if (AlwaysHasGlint.has(item.id.toString())) { return true } - if (item.id.equals(Identifier.create('compass')) && (item.tag.has('LodestoneDimension') || item.tag.has('LodestonePos'))) { + if (item.is('compass') && (item.tag.has('LodestoneDimension') || item.tag.has('LodestonePos'))) { return true } - if ((item.id.equals(Identifier.create('potion')) || item.id.equals(Identifier.create('splash_potion')) || item.id.equals(Identifier.create('lingering_potion'))) && (item.tag.has('Potion') || item.tag.has('CustomPotionEffects'))) { + if ((item.is('potion') || item.is('splash_potion') || item.is('lingering_potion')) && (item.tag.has('Potion') || item.tag.has('CustomPotionEffects'))) { return true } if (item.tag.getList('Enchantments').length > 0 || item.tag.getList('StoredEnchantments').length > 0) {