-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathRecipeMapScanner.java
More file actions
64 lines (53 loc) · 2.33 KB
/
Copy pathRecipeMapScanner.java
File metadata and controls
64 lines (53 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package gregtech.api.recipes.machines;
import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.builders.SimpleRecipeBuilder;
import gregtech.api.recipes.ui.RecipeMapUIFunction;
import gregtech.core.sound.GTSoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
@ApiStatus.Internal
public class RecipeMapScanner extends RecipeMap<SimpleRecipeBuilder> implements IScannerRecipeMap {
private static final List<ICustomScannerLogic> CUSTOM_SCANNER_LOGICS = new ArrayList<>();
public RecipeMapScanner(@NotNull String unlocalizedName, @NotNull SimpleRecipeBuilder defaultRecipeBuilder,
@NotNull RecipeMapUIFunction recipeMapUI) {
super(unlocalizedName, defaultRecipeBuilder, recipeMapUI, 2, 1, 1, 0);
setSound(GTSoundEvents.ELECTROLYZER);
getPrimaryRecipeCategory().jeiSortToBack(true);
}
@Override
public @NotNull List<Recipe> getRepresentativeRecipes() {
List<Recipe> recipes = new ArrayList<>();
for (ICustomScannerLogic logic : CUSTOM_SCANNER_LOGICS) {
List<Recipe> logicRecipes = logic.getRepresentativeRecipes();
if (logicRecipes != null && !logicRecipes.isEmpty()) {
recipes.addAll(logicRecipes);
}
}
return recipes;
}
/**
*
* @param logic A function which is passed the normal findRecipe() result. Returns null if no valid recipe for
* the custom logic is found,
*/
public static void registerCustomScannerLogic(ICustomScannerLogic logic) {
CUSTOM_SCANNER_LOGICS.add(logic);
}
@Override
@Nullable
public Recipe findRecipe(long voltage, List<ItemStack> inputs, List<FluidStack> fluidInputs, boolean exactVoltage) {
Recipe recipe = super.findRecipe(voltage, inputs, fluidInputs, exactVoltage);
if (recipe != null) return recipe;
for (ICustomScannerLogic logic : CUSTOM_SCANNER_LOGICS) {
recipe = logic.createCustomRecipe(voltage, inputs, fluidInputs, exactVoltage);
if (recipe != null) return recipe;
}
return null;
}
}