Skip to content

Commit

Permalink
fix(portal_spread): ⛑️Fix [Lapis Lazuli Ore] show wrong transformatio…
Browse files Browse the repository at this point in the history
…n in JEI

Also
- Better sort list of recipes
- Combine recipes with same output
  • Loading branch information
Krutoy242 committed Oct 16, 2024
1 parent 3a89d62 commit 532168d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion scripts/do/portal_spread/recipes.zs
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {};
Expand Down
30 changes: 22 additions & 8 deletions scripts/do/portal_spread/requious.zs
Original file line number Diff line number Diff line change
Expand Up @@ -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:')
? <item:${defId}:${state.block.meta}>
: 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 {
Expand All @@ -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;
Expand Down

0 comments on commit 532168d

Please sign in to comment.