From 325f4496e40e1763654c556df32eacb08f32cbd3 Mon Sep 17 00:00:00 2001 From: Zixxl Date: Wed, 1 Jul 2015 13:55:19 +0200 Subject: [PATCH] Added command to print TConstruct recipes --- src/main/java/modtweaker2/Commands.java | 2 + .../java/modtweaker2/helpers/InputHelper.java | 13 ++- .../tconstruct/commands/TConstructLogger.java | 101 ++++++++++++++++++ .../mods/tconstruct/handlers/Smeltery.java | 2 +- 4 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java diff --git a/src/main/java/modtweaker2/Commands.java b/src/main/java/modtweaker2/Commands.java index 6ddafed..9d10d0e 100644 --- a/src/main/java/modtweaker2/Commands.java +++ b/src/main/java/modtweaker2/Commands.java @@ -16,6 +16,7 @@ import modtweaker2.mods.chisel.commands.ChiselGroupLogger; import modtweaker2.mods.chisel.commands.ChiselVariationLogger; import modtweaker2.mods.mekanism.gas.GasLogger; import modtweaker2.mods.tconstruct.MaterialLogger; +import modtweaker2.mods.tconstruct.commands.TConstructLogger; import modtweaker2.mods.thaumcraft.commands.AspectLogger; import modtweaker2.mods.thaumcraft.research.commands.ResearchLogger; import modtweaker2.utils.TweakerPlugin; @@ -49,6 +50,7 @@ public class Commands { if (TweakerPlugin.isLoaded("TConstruct")) { MineTweakerAPI.server.addMineTweakerCommand("materials", new String[] { "/minetweaker materials", " Outputs a list of all Tinker's Construct material names in the game to the minetweaker log" }, new MaterialLogger()); + MineTweakerAPI.server.addMineTweakerCommand("tconstruct", new String[]{ "/minetweaker tconstruct [FILTER]", " Outputs a list of all Tinkers Construct recipes."}, new TConstructLogger()); } if (TweakerPlugin.isLoaded("Botania")) { diff --git a/src/main/java/modtweaker2/helpers/InputHelper.java b/src/main/java/modtweaker2/helpers/InputHelper.java index f95d2b1..d4a0e56 100644 --- a/src/main/java/modtweaker2/helpers/InputHelper.java +++ b/src/main/java/modtweaker2/helpers/InputHelper.java @@ -62,9 +62,20 @@ public class InputHelper { return sb.toString(); } else if (object instanceof FluidStack) { - return ""; + FluidStack stack = (FluidStack)object; + StringBuilder sb = new StringBuilder(); + + sb.append("'); + + if(stack.amount > 1) { + sb.append(" * ").append(stack.amount); + } + + return sb.toString(); } else if (object instanceof String) { List ores = OreDictionary.getOres((String)object); + + // Check if string specifies an oredict entry if(!ores.isEmpty()) { return ""; } else { diff --git a/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java b/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java new file mode 100644 index 0000000..57d505e --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java @@ -0,0 +1,101 @@ +package modtweaker2.mods.tconstruct.commands; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Map.Entry; + +import mantle.utils.ItemMetaWrapper; +import minetweaker.MineTweakerAPI; +import minetweaker.MineTweakerImplementationAPI; +import minetweaker.api.player.IPlayer; +import minetweaker.api.server.ICommandFunction; +import modtweaker2.helpers.InputHelper; +import modtweaker2.helpers.StringHelper; +import modtweaker2.mods.tconstruct.TConstructHelper; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import tconstruct.library.crafting.AlloyMix; +import tconstruct.library.crafting.CastingRecipe; +import tconstruct.library.crafting.DryingRackRecipes; +import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe; + +public class TConstructLogger implements ICommandFunction { + private static final List validArguments = new LinkedList(); + + static { + validArguments.add("casting"); + validArguments.add("drying"); + validArguments.add("smeltery"); + } + + @Override + public void execute(String[] arguments, IPlayer player) { + List args = StringHelper.toLowerCase(Arrays.asList(arguments)); + + if(!validArguments.containsAll(args)) { + player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); + } else { + if(args.isEmpty() || args.contains("casting")) { + for(CastingRecipe recipe : TConstructHelper.basinCasting) { + MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addBasinRecipe(%s, %s, %s, %s, %d);", + InputHelper.getStackDescription(recipe.output), + InputHelper.getStackDescription(recipe.castingMetal), + InputHelper.getStackDescription(recipe.cast), + recipe.consumeCast, + recipe.coolTime)); + } + + for(CastingRecipe recipe : TConstructHelper.tableCasting) { + MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addTableRecipe(%s, %s, %s, %s, %d);", + InputHelper.getStackDescription(recipe.output), + InputHelper.getStackDescription(recipe.castingMetal), + InputHelper.getStackDescription(recipe.cast), + recipe.consumeCast, + recipe.coolTime)); + } + } + + if(args.isEmpty() || args.contains("drying")) { + for(DryingRecipe recipe : DryingRackRecipes.recipes) { + MineTweakerAPI.logCommand(String.format("mods.tconstruct.Drying.addRecipe(%s, %s, %d);", + InputHelper.getStackDescription(recipe.input), + InputHelper.getStackDescription(recipe.result), + recipe.time)); + } + } + + if(args.isEmpty() || args.contains("smeltery")) { + + for(Entry recipe : TConstructHelper.smeltingList.entrySet()) { + int temperature = TConstructHelper.temperatureList.get(recipe.getKey()); + ItemStack renderItem = TConstructHelper.renderIndex.get(recipe.getKey()); + + MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addMelting(%s, %s, %d, %s);", + InputHelper.getStackDescription(new ItemStack(recipe.getKey().item, 1, recipe.getKey().meta)), + InputHelper.getStackDescription(recipe.getValue()), + temperature, + InputHelper.getStackDescription(renderItem))); + } + + for(AlloyMix recipe : TConstructHelper.alloys) { + MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addAlloy(%s, %s);", + InputHelper.getStackDescription(recipe.result), + InputHelper.getArrayDescription(recipe.mixers))); + } + + for(Entry fuel : TConstructHelper.fuelList.entrySet()) { + MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addFuel(%s, %d, %d);", + InputHelper.getStackDescription(new FluidStack(fuel.getKey(), 1)), + fuel.getValue()[0], + fuel.getValue()[1])); + } + } + + if (player != null) { + player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + } + } + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java index 352d5a0..01ce940 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java @@ -211,7 +211,7 @@ public class Smeltery { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod - public static void removFuel(IIngredient input) { + public static void removeFuel(IIngredient input) { Map recipes = new HashMap(); for(Entry fuel : TConstructHelper.fuelList.entrySet()) {