From 44ec007470f1104bcb57014f847d5c01ca582679 Mon Sep 17 00:00:00 2001 From: ZZZank <3410764033@qq.com> Date: Wed, 29 Nov 2023 00:35:46 +0800 Subject: [PATCH 1/2] use `try-catch` to handle `with` JavaScript's variable accessing is buggier than my expection --- kubejs/client_scripts/item_modifiers/jei_descriptions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kubejs/client_scripts/item_modifiers/jei_descriptions.js b/kubejs/client_scripts/item_modifiers/jei_descriptions.js index 00c5b42f2..551077286 100644 --- a/kubejs/client_scripts/item_modifiers/jei_descriptions.js +++ b/kubejs/client_scripts/item_modifiers/jei_descriptions.js @@ -491,9 +491,9 @@ onEvent('jei.information', (event) => { recipes.forEach((recipe) => { for (let i = 0; i < recipe.text.length; i++) { - if (recipe.with[i]) { + try { recipe.text[i] = Text.translate(recipe.text[i], recipe.with[i]); - } else { + } catch (e) { recipe.text[i] = Text.translate(recipe.text[i]); } } From 83c9efc2042fce3e2d0d8e51d32e4fa3842dc93d Mon Sep 17 00:00:00 2001 From: ZZZank <47418975+ZZZank@users.noreply.github.com> Date: Thu, 30 Nov 2023 22:14:18 +0800 Subject: [PATCH 2/2] Apply suggestions : `recipe.with && recipe.with.length > i` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Niels Pilgaard Grøndahl --- kubejs/client_scripts/item_modifiers/jei_descriptions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kubejs/client_scripts/item_modifiers/jei_descriptions.js b/kubejs/client_scripts/item_modifiers/jei_descriptions.js index 551077286..97c9a1653 100644 --- a/kubejs/client_scripts/item_modifiers/jei_descriptions.js +++ b/kubejs/client_scripts/item_modifiers/jei_descriptions.js @@ -491,9 +491,9 @@ onEvent('jei.information', (event) => { recipes.forEach((recipe) => { for (let i = 0; i < recipe.text.length; i++) { - try { + if (recipe.with && recipe.with.length > i) { recipe.text[i] = Text.translate(recipe.text[i], recipe.with[i]); - } catch (e) { + } else { recipe.text[i] = Text.translate(recipe.text[i]); } }