Added command to print TConstruct recipes

This commit is contained in:
Zixxl 2015-07-01 13:55:19 +02:00
parent 0929891f38
commit 325f4496e4
4 changed files with 116 additions and 2 deletions

View file

@ -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")) {

View file

@ -62,9 +62,20 @@ public class InputHelper {
return sb.toString();
} else if (object instanceof FluidStack) {
return "<liquid:" + ((FluidStack)object).getFluid().getName() + ">";
FluidStack stack = (FluidStack)object;
StringBuilder sb = new StringBuilder();
sb.append("<liquid:").append(stack.getFluid().getName()).append('>');
if(stack.amount > 1) {
sb.append(" * ").append(stack.amount);
}
return sb.toString();
} else if (object instanceof String) {
List<ItemStack> ores = OreDictionary.getOres((String)object);
// Check if string specifies an oredict entry
if(!ores.isEmpty()) {
return "<ore:" + (String)object + ">";
} else {

View file

@ -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<String> validArguments = new LinkedList<String>();
static {
validArguments.add("casting");
validArguments.add("drying");
validArguments.add("smeltery");
}
@Override
public void execute(String[] arguments, IPlayer player) {
List<String> 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<ItemMetaWrapper, FluidStack> 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<Fluid, Integer[]> 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"));
}
}
}
}

View file

@ -211,7 +211,7 @@ public class Smeltery {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removFuel(IIngredient input) {
public static void removeFuel(IIngredient input) {
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
for(Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {