Fix oreDict support for recipes in JEI
This commit is contained in:
parent
aed7b5c0c4
commit
6ce72c8339
6 changed files with 35 additions and 9 deletions
|
@ -1,24 +1,51 @@
|
|||
package techreborn.compat.jei;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import techreborn.api.recipe.BaseRecipe;
|
||||
|
||||
public abstract class BaseRecipeWrapper<T extends BaseRecipe> extends BlankRecipeWrapper {
|
||||
protected final T baseRecipe;
|
||||
private final List<List<ItemStack>> inputs;
|
||||
|
||||
public BaseRecipeWrapper(T baseRecipe) {
|
||||
this.baseRecipe = baseRecipe;
|
||||
|
||||
inputs = new ArrayList<>();
|
||||
for (ItemStack input : baseRecipe.getInputs()) {
|
||||
if (baseRecipe.useOreDic()) {
|
||||
int[] oreIds = OreDictionary.getOreIDs(input);
|
||||
if (oreIds.length > 0) {
|
||||
Set<ItemStack> itemStackSet = new HashSet<>();
|
||||
for (int oreId : oreIds) {
|
||||
String oreName = OreDictionary.getOreName(oreId);
|
||||
List<ItemStack> ores = OreDictionary.getOres(oreName);
|
||||
itemStackSet.addAll(ores);
|
||||
}
|
||||
inputs.add(new ArrayList<>(itemStackSet));
|
||||
} else {
|
||||
inputs.add(Collections.singletonList(input));
|
||||
}
|
||||
} else {
|
||||
inputs.add(Collections.singletonList(input));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getInputs() {
|
||||
return baseRecipe.getInputs();
|
||||
public List<List<ItemStack>> getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -74,7 +74,7 @@ public class BlastFurnaceRecipeCategory implements IRecipeCategory {
|
|||
if (recipeWrapper instanceof BlastFurnaceRecipeWrapper) {
|
||||
BlastFurnaceRecipeWrapper recipe = (BlastFurnaceRecipeWrapper) recipeWrapper;
|
||||
|
||||
List<ItemStack> inputs = recipe.getInputs();
|
||||
List<List<ItemStack>> inputs = recipe.getInputs();
|
||||
guiItemStacks.set(INPUT_SLOT_0, inputs.get(0));
|
||||
if (inputs.size() > 1) {
|
||||
guiItemStacks.set(INPUT_SLOT_1, inputs.get(1));
|
||||
|
|
|
@ -71,7 +71,7 @@ public class CentrifugeRecipeCategory implements IRecipeCategory {
|
|||
if (recipeWrapper instanceof CentrifugeRecipeWrapper) {
|
||||
CentrifugeRecipeWrapper recipe = (CentrifugeRecipeWrapper) recipeWrapper;
|
||||
|
||||
List<ItemStack> inputs = recipe.getInputs();
|
||||
List<List<ItemStack>> inputs = recipe.getInputs();
|
||||
guiItemStacks.set(INPUT_SLOT, inputs.get(0));
|
||||
if (inputs.size() > 1) {
|
||||
guiItemStacks.set(EMPTY_CELL_SLOT, inputs.get(1));
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ChemicalReactorRecipeCategory implements IRecipeCategory {
|
|||
if (recipeWrapper instanceof ChemicalReactorRecipeWrapper) {
|
||||
ChemicalReactorRecipeWrapper recipe = (ChemicalReactorRecipeWrapper) recipeWrapper;
|
||||
|
||||
List<ItemStack> inputs = recipe.getInputs();
|
||||
List<List<ItemStack>> inputs = recipe.getInputs();
|
||||
guiItemStacks.set(INPUT_SLOT_0, inputs.get(0));
|
||||
if (inputs.size() > 1) {
|
||||
guiItemStacks.set(INPUT_SLOT_1, inputs.get(1));
|
||||
|
|
|
@ -82,11 +82,10 @@ public class GrinderRecipeCategory implements IRecipeCategory {
|
|||
if (recipeWrapper instanceof GrinderRecipeWrapper) {
|
||||
GrinderRecipeWrapper recipe = (GrinderRecipeWrapper) recipeWrapper;
|
||||
|
||||
List<ItemStack> inputs = recipe.getInputs();
|
||||
List<List<ItemStack>> inputs = recipe.getInputs();
|
||||
for (int i = 0; i < inputs.size() && i < INPUT_SLOTS.length; i++) {
|
||||
int inputSlot = INPUT_SLOTS[i];
|
||||
ItemStack input = inputs.get(i);
|
||||
guiItemStacks.set(inputSlot, input);
|
||||
guiItemStacks.set(inputSlot, inputs.get(i));
|
||||
}
|
||||
|
||||
List<ItemStack> outputs = recipe.getOutputs();
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ImplosionCompressorRecipeCategory implements IRecipeCategory {
|
|||
if (recipeWrapper instanceof ImplosionCompressorRecipeWrapper) {
|
||||
ImplosionCompressorRecipeWrapper recipe = (ImplosionCompressorRecipeWrapper) recipeWrapper;
|
||||
|
||||
List<ItemStack> inputs = recipe.getInputs();
|
||||
List<List<ItemStack>> inputs = recipe.getInputs();
|
||||
guiItemStacks.set(INPUT_SLOT_0, inputs.get(0));
|
||||
if (inputs.size() > 1) {
|
||||
guiItemStacks.set(INPUT_SLOT_1, inputs.get(1));
|
||||
|
|
Loading…
Reference in a new issue