diff options
author | Raven Szewczyk <git@eigenraven.me> | 2024-05-23 17:17:54 +0100 |
---|---|---|
committer | Raven Szewczyk <git@eigenraven.me> | 2024-05-23 17:17:54 +0100 |
commit | 8f3f5f67388cf3319da2a7e31e1c47b0c654d81b (patch) | |
tree | 4b3cb1e4ac87ecd167d0aea4d7a1086991e86b13 /gigagramfab/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java | |
parent | 5150fdf3b3d86c8405d15435f26a8515f92d7492 (diff) | |
parent | 64de1cb440a4ee5e8c3afa83c3c024f3355a018b (diff) | |
download | GT5-Unofficial-8f3f5f67388cf3319da2a7e31e1c47b0c654d81b.tar.gz GT5-Unofficial-8f3f5f67388cf3319da2a7e31e1c47b0c654d81b.tar.bz2 GT5-Unofficial-8f3f5f67388cf3319da2a7e31e1c47b0c654d81b.zip |
Merge in GigaGramFab with history
git-subtree-dir: gigagramfab
git-subtree-mainline: 5150fdf3b3d86c8405d15435f26a8515f92d7492
git-subtree-split: 64de1cb440a4ee5e8c3afa83c3c024f3355a018b
Diffstat (limited to 'gigagramfab/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java')
-rw-r--r-- | gigagramfab/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/gigagramfab/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java b/gigagramfab/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java new file mode 100644 index 0000000000..088e9a7782 --- /dev/null +++ b/gigagramfab/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java @@ -0,0 +1,55 @@ +package net.glease.ggfab.api; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import net.glease.ggfab.GGItemList; +import net.minecraft.item.ItemStack; + +import com.gtnewhorizons.modularui.common.widget.ProgressBar; + +import gregtech.api.enums.ToolDictNames; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMapBackend; +import gregtech.api.recipe.RecipeMapBuilder; +import gregtech.api.recipe.RecipeMetadataKey; +import gregtech.api.recipe.metadata.SimpleRecipeMetadataKey; +import gregtech.api.util.GT_Recipe; + +public class GGFabRecipeMaps { + + public static final RecipeMetadataKey<ToolDictNames> OUTPUT_TYPE = SimpleRecipeMetadataKey + .create(ToolDictNames.class, "output_type"); + public static final RecipeMetadataKey<Integer> OUTPUT_COUNT = SimpleRecipeMetadataKey + .create(Integer.class, "output_count"); + public static final RecipeMap<RecipeMapBackend> toolCastRecipes = RecipeMapBuilder.of("ggfab.recipe.toolcast") + .maxIO(1, 4, 1, 0).minInputs(1, 1).progressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .recipeEmitter(b -> { + Optional<GT_Recipe> rr = b.noOptimize().validateNoInput().validateInputFluidCount(0, 1) + .validateNoOutput().validateNoOutputFluid().build(); + if (!rr.isPresent()) return Collections.emptyList(); + ToolDictNames outputType = b.getMetadata(OUTPUT_TYPE); + GT_Recipe r = rr.get(); + int outputSize = b.getMetadataOrDefault(OUTPUT_COUNT, 0); + if (outputSize > 64 * 4 || outputSize <= 0) return Collections.emptyList(); + ItemStack shape, output; + try { + shape = GGItemList.valueOf("Shape_One_Use_" + outputType).get(0L); + output = GGItemList.valueOf("One_Use_" + outputType).get(outputSize); + } catch (IllegalArgumentException ex) { + // this looks like python not java, but I don't have better way around this + return Collections.emptyList(); + } + output.stackSize = outputSize; + List<ItemStack> outputs = new ArrayList<>(); + int maxStackSize = output.getMaxStackSize(); + while (output.stackSize > maxStackSize) outputs.add(output.splitStack(maxStackSize)); + outputs.add(output); + r.mInputs = new ItemStack[] { shape }; + r.mOutputs = outputs.toArray(new ItemStack[0]); + return Collections.singletonList(r); + }).build(); +} |