From 532168dfa55dfbf3159a0deeccc12dee2e734fa8 Mon Sep 17 00:00:00 2001 From: Krutoy242 Date: Wed, 16 Oct 2024 14:15:45 +0300 Subject: [PATCH] =?UTF-8?q?fix(portal=5Fspread):=20=E2=9B=91=EF=B8=8FFix?= =?UTF-8?q?=20[Lapis=20Lazuli=20Ore]=20show=20wrong=20transformation=20in?= =?UTF-8?q?=20JEI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also - Better sort list of recipes - Combine recipes with same output --- scripts/do/portal_spread/recipes.zs | 2 +- scripts/do/portal_spread/requious.zs | 30 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/scripts/do/portal_spread/recipes.zs b/scripts/do/portal_spread/recipes.zs index e8c3e166a..04eca0bda 100644 --- a/scripts/do/portal_spread/recipes.zs +++ b/scripts/do/portal_spread/recipes.zs @@ -28,7 +28,7 @@ zenClass Spread { zenConstructor() {} // Recipes for exact inputState => outputState - val stateRecipes as IBlockState[][IBlockState][int][int] = {}; + val stateRecipes as IBlockState[][IBlockState][int][int] = {} as IBlockState[][IBlockState][int][int]$orderly; // Block numerical IDs that can be converted (completely or only some of their states) val transformableBlockNumIds as bool[int][int][int] = {}; diff --git a/scripts/do/portal_spread/requious.zs b/scripts/do/portal_spread/requious.zs index 29f0c9fc9..f99face0b 100644 --- a/scripts/do/portal_spread/requious.zs +++ b/scripts/do/portal_spread/requious.zs @@ -47,15 +47,34 @@ function stateToItem(state as IBlockState) as IItemStack { ) return null; val defId = state.block.definition.id; - var item = state.block.getItem(null, null, state); + var item = defId.startsWith('netherendingores:') + ? + : state.block.getItem(null, null, state); if (isNull(item)) item = blockRepresentation[defId]; if (isNull(item)) logger.logWarning('Cannot find item representation for block: ' ~ defId); return item; } +/** + * Compare two lists of items to be the same items and same amounts + */ +function isItemListSame(A as IItemStack[], B as IItemStack[]) as bool { + for a in A { + var match = false; + for b in B { + if (a has b || b has a) { + match = true; + break; + } + } + if (!match) return false; + } + return true; +} + // Group recipes by inputs and outputs -val recipeMap as IItemStack[][IIngredient] = {}; +val recipeMap as IItemStack[][IIngredient] = {} as IItemStack[][IIngredient]$orderly; for dimFrom, dimFromData in scripts.do.portal_spread.recipes.spread.stateRecipes { for dimTo, dimToData in dimFromData { @@ -80,12 +99,7 @@ for dimFrom, dimFromData in scripts.do.portal_spread.recipes.spread.stateRecipes for inp, outs in recipeMap { if (isNull(outs)) continue; - // Find if outputs are the same - var outsMatch = true; - for out in outs { if (!(outputs has out)) { outsMatch = false; break; } } - if (outsMatch) for out in outputs { if (!(outs has out)) { outsMatch = false; break; } } - - if (!outsMatch || inp has input) continue; + if (!isItemListSame(outs, outputs) || inp has input) continue; // Replace inputs recipeMap[inp] = null;