Files
ModTweaker/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java
T

103 lines
5.0 KiB
Java
Raw Normal View History

2015-07-01 13:55:19 +02:00
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;
2015-07-09 11:28:40 +02:00
import modtweaker2.helpers.LogHelper;
2015-07-01 13:55:19 +02:00
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 {
2015-09-02 18:45:34 +02:00
validArguments.add("Casting");
validArguments.add("Drying");
validArguments.add("Smeltery");
2015-07-01 13:55:19 +02:00
}
@Override
public void execute(String[] arguments, IPlayer player) {
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
if(!validArguments.containsAll(args)) {
2015-07-03 17:09:37 +02:00
if(player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
}
2015-07-01 13:55:19 +02:00
} else {
2015-09-02 18:45:34 +02:00
if(args.isEmpty() || args.contains("Casting")) {
2015-07-01 13:55:19 +02:00
for(CastingRecipe recipe : TConstructHelper.basinCasting) {
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addBasinRecipe(%s, %s, %s, %s, %d);",
2015-07-09 11:28:40 +02:00
LogHelper.getStackDescription(recipe.output),
LogHelper.getStackDescription(recipe.castingMetal),
LogHelper.getStackDescription(recipe.cast),
2015-07-01 13:55:19 +02:00
recipe.consumeCast,
recipe.coolTime));
}
for(CastingRecipe recipe : TConstructHelper.tableCasting) {
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addTableRecipe(%s, %s, %s, %s, %d);",
2015-07-09 11:28:40 +02:00
LogHelper.getStackDescription(recipe.output),
LogHelper.getStackDescription(recipe.castingMetal),
LogHelper.getStackDescription(recipe.cast),
2015-07-01 13:55:19 +02:00
recipe.consumeCast,
recipe.coolTime));
}
}
2015-09-02 18:45:34 +02:00
if(args.isEmpty() || args.contains("Drying")) {
2015-07-01 13:55:19 +02:00
for(DryingRecipe recipe : DryingRackRecipes.recipes) {
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Drying.addRecipe(%s, %s, %d);",
2015-07-09 11:28:40 +02:00
LogHelper.getStackDescription(recipe.input),
LogHelper.getStackDescription(recipe.result),
2015-07-01 13:55:19 +02:00
recipe.time));
}
}
2015-09-02 18:45:34 +02:00
if(args.isEmpty() || args.contains("Smeltery")) {
2015-07-01 13:55:19 +02:00
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);",
2015-07-09 11:28:40 +02:00
LogHelper.getStackDescription(new ItemStack(recipe.getKey().item, 1, recipe.getKey().meta)),
LogHelper.getStackDescription(recipe.getValue()),
2015-07-01 13:55:19 +02:00
temperature,
2015-07-09 11:28:40 +02:00
LogHelper.getStackDescription(renderItem)));
2015-07-01 13:55:19 +02:00
}
for(AlloyMix recipe : TConstructHelper.alloys) {
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addAlloy(%s, %s);",
2015-07-09 11:28:40 +02:00
LogHelper.getStackDescription(recipe.result),
LogHelper.getListDescription(recipe.mixers)));
2015-07-01 13:55:19 +02:00
}
for(Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addFuel(%s, %d, %d);",
2015-07-09 11:28:40 +02:00
LogHelper.getStackDescription(new FluidStack(fuel.getKey(), 1)),
2015-07-01 13:55:19 +02:00
fuel.getValue()[0],
fuel.getValue()[1]));
}
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}
}