Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 566da95

Browse files
authored
fix: axes missing in farming tools (#1885)
* fix: axes missing in farming tools * style: `npm run prettier:fix` * refactor: move line
1 parent c503f5a commit 566da95

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/constants/items.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,20 @@ export const TYPE_TO_CATEGORIES = {
3333
deployable: ["deployable"],
3434
"trophy fish": ["trophy_fish"],
3535
};
36+
37+
export const ENCHANTMENTS_TO_CATEGORIES = {
38+
farming_tool: [
39+
"delicate",
40+
"harvesting",
41+
"cultivating",
42+
"replenish",
43+
"turbo_cacti",
44+
"turbo_cane",
45+
"turbo_carrot",
46+
"turbo_mushrooms",
47+
"turbo_potato",
48+
"turbo_warts",
49+
"turbo_wheat",
50+
"sunder",
51+
],
52+
};

src/helper.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
RARITY_COLORS,
2424
HOTM,
2525
TYPE_TO_CATEGORIES,
26+
ENCHANTMENTS_TO_CATEGORIES,
2627
PET_DATA,
2728
PET_RARITY_OFFSET,
2829
PET_LEVELS,
@@ -915,7 +916,7 @@ export function convertHMS(seconds, format = "clock", alwaysTwoDigits = false) {
915916
}
916917
}
917918

918-
export function parseItemTypeFromLore(lore) {
919+
export function parseItemTypeFromLore(lore, item) {
919920
const regex = new RegExp(
920921
`^(?<recomb>a )?(?<shiny>SHINY )?(?:(?<rarity>${RARITIES.map((x) => x.replaceAll("_", " ").toUpperCase()).join(
921922
"|"
@@ -947,7 +948,7 @@ export function parseItemTypeFromLore(lore) {
947948
// Parsing the match and returning data
948949
const r = match.groups;
949950
return {
950-
categories: r.type ? getCategoriesFromType(r.type.trim().toLowerCase()) : [],
951+
categories: r.type ? getCategories(r.type.trim().toLowerCase(), item) : [],
951952
rarity: r.rarity.replaceAll(" ", "_").toLowerCase(),
952953
recombobulated: !!r.recomb && !!r.recomb2,
953954
dungeon: !!r.dungeon,
@@ -997,8 +998,17 @@ export function getCacheFilePath(dirPath, type, name, format = "png") {
997998
return path.resolve(dirPath, `${subdirs.join("/")}/${type}_${name}.${format}`);
998999
}
9991000

1000-
function getCategoriesFromType(type) {
1001-
return TYPE_TO_CATEGORIES[type] ?? ["unknown"];
1001+
function getCategories(type, item) {
1002+
const categories = [];
1003+
1004+
const enchantments = item?.tag?.ExtraAttributes?.enchantments || {};
1005+
Object.keys(enchantments).forEach((enchantment) =>
1006+
Object.entries(ENCHANTMENTS_TO_CATEGORIES).forEach(
1007+
([category, enchantmentList]) => enchantmentList.includes(enchantment) && categories.push(category)
1008+
)
1009+
);
1010+
1011+
return [...new Set(categories.concat(TYPE_TO_CATEGORIES[type]))];
10021012
}
10031013

10041014
export function generateDebugPets(type = "ALL") {

src/lib.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ async function processItems(base64, source, customTextures = false, packs, cache
555555

556556
if (lore.length > 0) {
557557
// item categories, rarity, recombobulated, dungeon, shiny
558-
const itemType = helper.parseItemTypeFromLore(lore);
558+
const itemType = helper.parseItemTypeFromLore(lore, item);
559559

560560
for (const key in itemType) {
561561
item[key] = itemType[key];

0 commit comments

Comments
 (0)