From 1b820de08a05070909a267e17f033fcf58ac8710 Mon Sep 17 00:00:00 2001 From: NotAPenguin Date: Mon, 2 Sep 2024 23:17:17 +0200 Subject: The Great Renaming (#3014) * move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names --- src/main/java/ggfab/api/GGFabRecipeMaps.java | 64 ++++++++++++++++++++++++++++ src/main/java/ggfab/api/GigaGramFabAPI.java | 30 +++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/main/java/ggfab/api/GGFabRecipeMaps.java create mode 100644 src/main/java/ggfab/api/GigaGramFabAPI.java (limited to 'src/main/java/ggfab/api') diff --git a/src/main/java/ggfab/api/GGFabRecipeMaps.java b/src/main/java/ggfab/api/GGFabRecipeMaps.java new file mode 100644 index 0000000000..cd2663f944 --- /dev/null +++ b/src/main/java/ggfab/api/GGFabRecipeMaps.java @@ -0,0 +1,64 @@ +package ggfab.api; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import net.minecraft.item.ItemStack; + +import com.gtnewhorizons.modularui.common.widget.ProgressBar; + +import ggfab.GGItemList; +import gregtech.api.enums.ToolDictNames; +import gregtech.api.gui.modularui.GTUITextures; +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.GTRecipe; + +public class GGFabRecipeMaps { + + public static final RecipeMetadataKey OUTPUT_TYPE = SimpleRecipeMetadataKey + .create(ToolDictNames.class, "output_type"); + public static final RecipeMetadataKey OUTPUT_COUNT = SimpleRecipeMetadataKey + .create(Integer.class, "output_count"); + public static final RecipeMap toolCastRecipes = RecipeMapBuilder.of("ggfab.recipe.toolcast") + .maxIO(1, 4, 1, 0) + .minInputs(1, 1) + .progressBar(GTUITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .recipeEmitter(b -> { + Optional rr = b.noOptimize() + .validateNoInput() + .validateInputFluidCount(0, 1) + .validateNoOutput() + .validateNoOutputFluid() + .build(); + if (!rr.isPresent()) return Collections.emptyList(); + ToolDictNames outputType = b.getMetadata(OUTPUT_TYPE); + GTRecipe 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 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(); +} diff --git a/src/main/java/ggfab/api/GigaGramFabAPI.java b/src/main/java/ggfab/api/GigaGramFabAPI.java new file mode 100644 index 0000000000..3eb4862059 --- /dev/null +++ b/src/main/java/ggfab/api/GigaGramFabAPI.java @@ -0,0 +1,30 @@ +package ggfab.api; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import gregtech.api.enums.ToolDictNames; +import gregtech.api.interfaces.IToolStats; + +public class GigaGramFabAPI { + + private static final Logger apiLogger = LogManager.getLogger("GigaGramFabAPI"); + + private static final Map SINGLE_USE_TOOLS_STORE = new HashMap<>(); + public static final Map SINGLE_USE_TOOLS = Collections + .unmodifiableMap(SINGLE_USE_TOOLS_STORE); + + private static final Map COST_SINGLE_USE_TOOLS_STORE = new HashMap<>(); + public static final Map COST_SINGLE_USE_TOOLS = Collections + .unmodifiableMap(COST_SINGLE_USE_TOOLS_STORE); + + public static void addSingleUseToolType(ToolDictNames type, IToolStats stat, long materialCost) { + if (SINGLE_USE_TOOLS_STORE.put(type, stat) != null) + apiLogger.warn("Replacing stat of single use tool {}", type); + COST_SINGLE_USE_TOOLS_STORE.put(type, materialCost); + } +} -- cgit