diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-08-21 13:36:14 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-08-21 13:36:14 -0400 |
commit | 03bcc47f9994523b61b1bea06cec718a43700c83 (patch) | |
tree | 015922aa79762bbfcda23e1388195c62357c16d0 | |
parent | be60d01553dc4e948c8c13400d5a4932fd741ed8 (diff) | |
download | tanzanite-03bcc47f9994523b61b1bea06cec718a43700c83.tar.gz tanzanite-03bcc47f9994523b61b1bea06cec718a43700c83.tar.bz2 tanzanite-03bcc47f9994523b61b1bea06cec718a43700c83.zip |
fix wip mc stuff
-rw-r--r-- | lib/utils/Minecraft.ts | 51 | ||||
-rw-r--r-- | lib/utils/Minecraft_Test.ts | 51 |
2 files changed, 51 insertions, 51 deletions
diff --git a/lib/utils/Minecraft.ts b/lib/utils/Minecraft.ts index bb5fbfe..50c44ef 100644 --- a/lib/utils/Minecraft.ts +++ b/lib/utils/Minecraft.ts @@ -1,6 +1,6 @@ /* eslint-disable */ -import { Byte, Int, parse } from '@ironm00n/nbt-ts'; +import { Byte, Int } from '@ironm00n/nbt-ts'; import { BitField } from 'discord.js'; import path from 'path'; import { fileURLToPath } from 'url'; @@ -224,8 +224,6 @@ export function removeMCFormatting(str: string) { return str.replaceAll(formattingCode, ''); } -const repo = path.join(__dirname, '..', '..', '..', 'neu-item-repo-dangerous'); - export interface NbtTag { overrideMeta?: Byte; Unbreakable?: Int; @@ -273,12 +271,6 @@ export interface PetInfo { export type Origin = 'SHOP_PURCHASE'; -const neuConstantsPath = path.join(repo, 'constants'); -const neuPetsPath = path.join(neuConstantsPath, 'pets.json'); -const neuPets = (await import(neuPetsPath, { assert: { type: 'json' } })) as PetsConstants; -const neuPetNumsPath = path.join(neuConstantsPath, 'petnums.json'); -const neuPetNums = (await import(neuPetNumsPath, { assert: { type: 'json' } })) as PetNums; - export interface PetsConstants { pet_rarity_offset: Record<string, number>; pet_levels: number[]; @@ -302,47 +294,6 @@ export interface PetNums { }; } -export class NeuItem { - public itemId: McItemId; - public displayName: string; - public nbtTag: NbtTag; - public internalName: SbItemId; - public lore: string[]; - - public constructor(raw: RawNeuItem) { - this.itemId = raw.itemid; - this.nbtTag = <NbtTag>parse(raw.nbttag); - this.displayName = raw.displayname; - this.internalName = raw.internalname; - this.lore = raw.lore; - - this.petLoreReplacements(); - } - - private petLoreReplacements(level = -1) { - if (/.*?;[0-5]$/.test(this.internalName) && this.displayName.includes('LVL')) { - const maxLevel = neuPets?.custom_pet_leveling?.[this.internalName]?.max_level ?? 100; - this.displayName = this.displayName.replace('LVL', `1➡${maxLevel}`); - - const nums = neuPetNums[this.internalName]; - if (!nums) throw new Error(`Pet (${this.internalName}) has no pet nums.`); - - const teir = ['COMMON', 'UNCOMMON', 'RARE', 'EPIC', 'LEGENDARY', 'MYTHIC'][+this.internalName.at(-1)!]; - const petInfoTier = nums[teir]; - if (!petInfoTier) throw new Error(`Pet (${this.internalName}) has no pet nums for ${teir} rarity.`); - - const curve = petInfoTier?.stats_levelling_curve?.split(';'); - - // todo: finish copying from neu - - const minStatsLevel = parseInt(curve?.[0] ?? '0'); - const maxStatsLevel = parseInt(curve?.[0] ?? '100'); - - const lore = ''; - } - } -} - export function mcToAnsi(str: string) { for (const format in formattingInfo) { str = str.replaceAll(format, formattingInfo[format as keyof typeof formattingInfo].ansi); diff --git a/lib/utils/Minecraft_Test.ts b/lib/utils/Minecraft_Test.ts index 26ca648..fce9d5b 100644 --- a/lib/utils/Minecraft_Test.ts +++ b/lib/utils/Minecraft_Test.ts @@ -1,7 +1,10 @@ +/* eslint-disable */ + +import { parse } from '@ironm00n/nbt-ts'; import fs from 'fs/promises'; import path from 'path'; import { fileURLToPath } from 'url'; -import { mcToAnsi, RawNeuItem } from './Minecraft.js'; +import { McItemId, mcToAnsi, NbtTag, PetNums, PetsConstants, RawNeuItem, SbItemId } from './Minecraft.js'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const repo = path.join(__dirname, '..', '..', '..', '..', '..', 'neu-item-repo-dangerous'); @@ -84,3 +87,49 @@ for (const path_ of items) { /* console.log('=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-'); */ } +const neuConstantsPath = path.join(repo, 'constants'); +const neuPetsPath = path.join(neuConstantsPath, 'pets.json'); +const neuPets = (await import(neuPetsPath, { assert: { type: 'json' } })) as PetsConstants; +const neuPetNumsPath = path.join(neuConstantsPath, 'petnums.json'); +const neuPetNums = (await import(neuPetNumsPath, { assert: { type: 'json' } })) as PetNums; + +export class NeuItem { + public itemId: McItemId; + public displayName: string; + public nbtTag: NbtTag; + public internalName: SbItemId; + public lore: string[]; + + public constructor(raw: RawNeuItem) { + this.itemId = raw.itemid; + this.nbtTag = <NbtTag>parse(raw.nbttag); + this.displayName = raw.displayname; + this.internalName = raw.internalname; + this.lore = raw.lore; + + this.petLoreReplacements(); + } + + private petLoreReplacements(level = -1) { + if (/.*?;[0-5]$/.test(this.internalName) && this.displayName.includes('LVL')) { + const maxLevel = neuPets?.custom_pet_leveling?.[this.internalName]?.max_level ?? 100; + this.displayName = this.displayName.replace('LVL', `1➡${maxLevel}`); + + const nums = neuPetNums[this.internalName]; + if (!nums) throw new Error(`Pet (${this.internalName}) has no pet nums.`); + + const teir = ['COMMON', 'UNCOMMON', 'RARE', 'EPIC', 'LEGENDARY', 'MYTHIC'][+this.internalName.at(-1)!]; + const petInfoTier = nums[teir]; + if (!petInfoTier) throw new Error(`Pet (${this.internalName}) has no pet nums for ${teir} rarity.`); + + const curve = petInfoTier?.stats_levelling_curve?.split(';'); + + // todo: finish copying from neu + + const minStatsLevel = parseInt(curve?.[0] ?? '0'); + const maxStatsLevel = parseInt(curve?.[0] ?? '100'); + + const lore = ''; + } + } +} |