Added command to print AE2 recipes

- Added command "/mt ae2" to log all Applied Energistics 2 recipes.
This commit is contained in:
Zixxl committed 2015-06-30 01:37:30 +02:00
1 parent f8d537e857
commit 152fa40b9a
3 files changed
+73 -2

No files matched your search

+5
View File
@@ -4,6 +4,7 @@ import minetweaker.MineTweakerAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.commands.EntityMappingLogger;
import modtweaker2.mods.appeng.Commands.AppliedEnergisticsLogger;
import modtweaker2.mods.auracascade.aura.AuraLogger;
import modtweaker2.mods.botania.commands.BotaniaBrewLogger;
import modtweaker2.mods.botania.commands.BotaniaOrechidLogger;
@@ -31,6 +32,10 @@ public class Commands {
});
MineTweakerAPI.server.addMineTweakerCommand("entities", new String[] { "/minetweaker entities", " Outputs a list of entities class mapping keys and the entity IDs" }, new EntityMappingLogger());
if (TweakerPlugin.isLoaded("appliedenergistics2-core")) {
MineTweakerAPI.server.addMineTweakerCommand("ae2", new String[] {"/minetweaker ae2 ([Grinder/Inscriber])", " Outputs a list of all Applied Energistics 2 recipes."}, new AppliedEnergisticsLogger());
}
if (TweakerPlugin.isLoaded("Mekanism")) {
MineTweakerAPI.server.addMineTweakerCommand("gases", new String[] { "/minetweaker gases", " Outputs a list of all gas names in the game to the minetweaker log" }, new GasLogger());
@@ -59,7 +59,7 @@ public class InputHelper {
return sb.toString();
} else {
return "null object";
return "null";
}
}
@@ -67,7 +67,7 @@ public class InputHelper {
if(stack != null) {
return "<liquid:" + stack.getFluid().getName() + ">";
} else {
return "null object";
return "null";
}
}
@@ -0,0 +1,66 @@
package modtweaker2.mods.appeng.Commands;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import modtweaker2.helpers.InputHelper;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.features.IGrinderEntry;
import appeng.api.features.IInscriberRecipe;
public class AppliedEnergisticsLogger implements ICommandFunction {
@Override
public void execute(String[] arguments, IPlayer player) {
List<String> args = new LinkedList<String>();
for(String arg : arguments) {
args.add(arg.toLowerCase());
}
if(args.isEmpty() || args.contains("grinder")) {
for(IGrinderEntry recipe : AEApi.instance().registries().grinder().getRecipes()) {
MineTweakerAPI.logCommand(String.format("mods.appeng.Grinder.addRecipe(%s, %s, %d, %s, %s, %s, %s);",
InputHelper.getStackDescription(recipe.getInput()),
InputHelper.getStackDescription(recipe.getOutput()),
recipe.getEnergyCost(),
InputHelper.getStackDescription(recipe.getOptionalOutput()),
recipe.getOptionalChance(),
InputHelper.getStackDescription(recipe.getSecondOptionalOutput()),
recipe.getSecondOptionalChance()));
}
}
if(args.isEmpty() || args.contains("inscriber")) {
for(IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes()) {
MineTweakerAPI.logCommand(String.format("mods.appeng.Inscriber.addRecipe(%s, %s, %s, %s, \"%s\");",
getArrayDescription(recipe.getInputs()),
InputHelper.getStackDescription(recipe.getTopOptional().orNull()),
InputHelper.getStackDescription(recipe.getBottomOptional().orNull()),
InputHelper.getStackDescription(recipe.getOutput()),
recipe.getProcessType().toString()));
}
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
private String getArrayDescription(List<ItemStack> stacks) {
StringBuilder sb = new StringBuilder();
sb.append('[');
for(ItemStack stack : stacks) {
sb.append(InputHelper.getStackDescription(stack)).append(", ");
}
sb.setLength(sb.length() - 2);
sb.append(']');
return sb.toString();
}
}