From 4dcb9af87184f2f90ceece0f504abed1f039b092 Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Sat, 10 May 2014 22:08:23 +0200 Subject: [PATCH] added possibility to blacklist recipes, close #1750 --- common/buildcraft/BuildCraftCore.java | 13 +++++++++++++ common/buildcraft/core/proxy/CoreProxy.java | 17 ++++++++++++++--- .../core/recipes/AssemblyRecipeManager.java | 7 +++++++ .../core/recipes/RefineryRecipeManager.java | 13 +++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 221f8420..5fb0289e 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -12,6 +12,7 @@ import java.io.File; import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.util.HashSet; import java.util.TreeMap; import org.lwjgl.input.Mouse; @@ -56,6 +57,7 @@ import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.api.core.BCLog; import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.IIconProvider; +import buildcraft.api.core.JavaTools; import buildcraft.api.gates.ActionManager; import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.builders.urbanism.EntityRobotUrbanism; @@ -199,6 +201,8 @@ public class BuildCraftCore extends BuildCraftMod { public static AchievementPage BuildcraftAchievements; + public static HashSet recipesBlacklist = new HashSet(); + public static float diffX, diffY, diffZ; private static FloatBuffer modelviewF; @@ -322,6 +326,15 @@ public class BuildCraftCore extends BuildCraftMod { MinecraftForge.EVENT_BUS.register(new SpringPopulate()); } + for (String l : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, + "recipesBlacklist", new String[0]).getStringList()) { + recipesBlacklist.add(JavaTools.stripSurroundingQuotes(l.trim())); + } + + if (mainConfiguration.hasChanged()) { + mainConfiguration.save(); + } + if (BuildCraftCore.loadDefaultRecipes) { loadRecipes(); } diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java index 16f94e91..42671ccb 100644 --- a/common/buildcraft/core/proxy/CoreProxy.java +++ b/common/buildcraft/core/proxy/CoreProxy.java @@ -36,6 +36,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; +import buildcraft.BuildCraftCore; import buildcraft.api.core.ICoreProxy; import buildcraft.core.EntityBlock; import buildcraft.core.ItemBlockBuildCraft; @@ -110,13 +111,23 @@ public class CoreProxy implements ICoreProxy { @SuppressWarnings("unchecked") public void addCraftingRecipe(ItemStack result, Object... recipe) { + String name = Item.itemRegistry.getNameForObject(result.getItem()); + + if (BuildCraftCore.recipesBlacklist.contains(name)) { + return; + } + CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(result, recipe)); - //GameRegistry.addRecipe(result, recipe); } public void addShapelessRecipe(ItemStack result, Object... recipe) { - CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(result, recipe)); - //GameRegistry.addShapelessRecipe(result, recipe); + String name = Item.itemRegistry.getNameForObject(result.getItem()); + + if (BuildCraftCore.recipesBlacklist.contains(name)) { + return; + } + + CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(result, recipe)); } public int addCustomTexture(String pathToTexture) { diff --git a/common/buildcraft/core/recipes/AssemblyRecipeManager.java b/common/buildcraft/core/recipes/AssemblyRecipeManager.java index 39e1d90b..f0ddc69e 100644 --- a/common/buildcraft/core/recipes/AssemblyRecipeManager.java +++ b/common/buildcraft/core/recipes/AssemblyRecipeManager.java @@ -19,6 +19,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; +import buildcraft.BuildCraftCore; import buildcraft.api.core.IInvSlot; import buildcraft.api.recipes.IAssemblyRecipeManager; import buildcraft.core.inventory.ITransactor; @@ -33,6 +34,12 @@ public class AssemblyRecipeManager implements IAssemblyRecipeManager { @Override public void addRecipe(double energyCost, ItemStack output, Object... input) { + String name = Item.itemRegistry.getNameForObject(output.getItem()); + + if (BuildCraftCore.recipesBlacklist.contains(name)) { + return; + } + assemblyRecipes.add(new AssemblyRecipe(output, energyCost, input)); } diff --git a/common/buildcraft/core/recipes/RefineryRecipeManager.java b/common/buildcraft/core/recipes/RefineryRecipeManager.java index e7a06956..3f537de4 100644 --- a/common/buildcraft/core/recipes/RefineryRecipeManager.java +++ b/common/buildcraft/core/recipes/RefineryRecipeManager.java @@ -16,6 +16,7 @@ import com.google.common.base.Objects; import net.minecraftforge.fluids.FluidStack; +import buildcraft.BuildCraftCore; import buildcraft.api.recipes.IRefineryRecipeManager; public final class RefineryRecipeManager implements IRefineryRecipeManager { @@ -28,11 +29,23 @@ public final class RefineryRecipeManager implements IRefineryRecipeManager { @Override public void addRecipe(FluidStack ingredient, FluidStack result, int energy, int delay) { + String name = result.getFluid().getName(); + + if (BuildCraftCore.recipesBlacklist.contains(name)) { + return; + } + addRecipe(ingredient, null, result, energy, delay); } @Override public void addRecipe(FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay) { + String name = result.getFluid().getName(); + + if (BuildCraftCore.recipesBlacklist.contains(name)) { + return; + } + RefineryRecipe recipe = new RefineryRecipe(ingredient1, ingredient2, result, energy, delay); recipes.add(recipe); }