Add ore dictionary support for Inscriber recipes in JEI (#430)

This commit is contained in:
zeng-git
2024-05-24 18:51:37 +08:00
committed by GitHub
parent 08a7aff600
commit 59edb38208
10 changed files with 127 additions and 108 deletions
@@ -31,9 +31,7 @@ import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
@@ -49,25 +47,15 @@ public class InscriberRecipes {
return;
}
Collection<ItemStack> topList = CTModule.toStacks(top).orElse(Collections.singleton(ItemStack.EMPTY));
Collection<ItemStack> bottomList = CTModule.toStacks(bottom).orElse(Collections.singleton(ItemStack.EMPTY));
for (ItemStack topStack : topList) {
for (ItemStack bottomStack : bottomList) {
final IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder();
builder.withProcessType(inscribe ? InscriberProcessType.INSCRIBE : InscriberProcessType.PRESS)
.withOutput(CTModule.toStack(output))
.withInputs(inStacks.get());
if (!topStack.isEmpty()) {
builder.withTopOptional(topStack);
}
if (!bottomStack.isEmpty()) {
builder.withBottomOptional(bottomStack);
}
CTModule.MODIFICATIONS.add(new Add(builder.build()));
}
}
List<ItemStack> topList = new ArrayList<>(CTModule.toStacks(top).orElse(Collections.singleton(ItemStack.EMPTY)));
List<ItemStack> bottomList = new ArrayList<>(CTModule.toStacks(bottom).orElse(Collections.singleton(ItemStack.EMPTY)));
final IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder();
builder.withProcessType(inscribe ? InscriberProcessType.INSCRIBE : InscriberProcessType.PRESS).
withTopOptional(topList).
withBottomOptional(bottomList).
withOutput(CTModule.toStack(output))
.withInputs(inStacks.get());
CTModule.MODIFICATIONS.add(new Add(builder.build()));
}
@ZenMethod
@@ -21,11 +21,11 @@ package appeng.integration.modules.jei;
import appeng.api.features.IInscriberRecipe;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -40,11 +40,10 @@ class InscriberRecipeWrapper implements IRecipeWrapper {
@Override
public void getIngredients(IIngredients ingredients) {
List<List<ItemStack>> inputSlots = new ArrayList<>(3);
inputSlots.add(Collections.singletonList(this.recipe.getTopOptional().orElse(ItemStack.EMPTY)));
inputSlots.add(this.recipe.getTopInputs());
inputSlots.add(this.recipe.getInputs());
inputSlots.add(Collections.singletonList(this.recipe.getBottomOptional().orElse(ItemStack.EMPTY)));
ingredients.setInputLists(ItemStack.class, inputSlots);
ingredients.setOutput(ItemStack.class, this.recipe.getOutput());
inputSlots.add(this.recipe.getBottomInputs());
ingredients.setInputLists(VanillaTypes.ITEM, inputSlots);
ingredients.setOutput(VanillaTypes.ITEM, this.recipe.getOutput());
}
}