From c69b9f46b668047186f6565b3795398f937c7978 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Fri, 19 Jan 2018 11:17:36 +0300 Subject: [PATCH] Added ability to remove fluidgenerator recipe via CT. Closes #1404 --- .../api/generator/GeneratorRecipeHelper.java | 15 ++++++++++ .../compat/crafttweaker/CTFluidGen.java | 29 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/main/java/techreborn/api/generator/GeneratorRecipeHelper.java b/src/main/java/techreborn/api/generator/GeneratorRecipeHelper.java index 991d2ea77..e0db3d352 100644 --- a/src/main/java/techreborn/api/generator/GeneratorRecipeHelper.java +++ b/src/main/java/techreborn/api/generator/GeneratorRecipeHelper.java @@ -27,6 +27,7 @@ package techreborn.api.generator; import net.minecraftforge.fluids.Fluid; import java.util.EnumMap; +import java.util.Optional; public class GeneratorRecipeHelper { @@ -62,4 +63,18 @@ public class GeneratorRecipeHelper { public static FluidGeneratorRecipeList getFluidRecipesForGenerator(EFluidGenerator generatorType) { return fluidRecipes.get(generatorType); } + + /** + * Removes recipe + * + * @param generatorType A value of the EFluidGenerator type for which we should remove recipe + * @param fluidType Fluid to remove from generator recipes + */ + public static void removeFluidRecipe(EFluidGenerator generatorType, Fluid fluidType) { + FluidGeneratorRecipeList recipeList = getFluidRecipesForGenerator(generatorType); + Optional recipe = recipeList.getRecipeForFluid(fluidType); + if (recipe.isPresent()) { + recipeList.removeRecipe(recipe.get()); + } + } } diff --git a/src/main/java/techreborn/compat/crafttweaker/CTFluidGen.java b/src/main/java/techreborn/compat/crafttweaker/CTFluidGen.java index 8958b0439..ab8f9ce51 100644 --- a/src/main/java/techreborn/compat/crafttweaker/CTFluidGen.java +++ b/src/main/java/techreborn/compat/crafttweaker/CTFluidGen.java @@ -58,7 +58,36 @@ public class CTFluidGen { addFluid(EFluidGenerator.PLASMA, fluid, energyPerMb); } + @ZenMethod + public static void removeThermalFluid(ILiquidStack fluid) { + removeFluid(EFluidGenerator.THERMAL, fluid); + } + + @ZenMethod + public static void removeGasFluid(ILiquidStack fluid) { + removeFluid(EFluidGenerator.GAS, fluid); + } + + @ZenMethod + public static void removeSemiFluid(ILiquidStack fluid) { + removeFluid(EFluidGenerator.SEMIFLUID, fluid); + } + + @ZenMethod + public static void removeDieselFluid(ILiquidStack fluid) { + removeFluid(EFluidGenerator.DIESEL, fluid); + } + + @ZenMethod + public static void removePlasmaFluid(ILiquidStack fluid) { + removeFluid(EFluidGenerator.PLASMA, fluid); + } + private static void addFluid(EFluidGenerator type, ILiquidStack fluid, int energyPerMb) { GeneratorRecipeHelper.registerFluidRecipe(type, CraftTweakerCompat.toFluidStack(fluid).getFluid(), energyPerMb); } + + private static void removeFluid(EFluidGenerator type, ILiquidStack fluid) { + GeneratorRecipeHelper.removeFluidRecipe(type, CraftTweakerCompat.toFluidStack(fluid).getFluid()); + } }