mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-19 03:59:08 +00:00
Minor improvements for AE2 recipe logging
This commit is contained in:
1 parent
152fa40b9a
commit
a0a8f2f26e
4 files changed
+87
-48
No files matched your search
@@ -1,66 +1,62 @@
|
||||
package modtweaker2.mods.appeng.Commands;
|
||||
package modtweaker2.mods.appeng.commands;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Arrays;
|
||||
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 modtweaker2.helpers.LogHelper;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IGrinderEntry;
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
|
||||
public class AppliedEnergisticsLogger implements ICommandFunction {
|
||||
|
||||
private static final List<String> validArguments = new LinkedList<String>();
|
||||
|
||||
static {
|
||||
validArguments.add("grinder");
|
||||
validArguments.add("inscriber");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
List<String> args = new LinkedList<String>();
|
||||
List<String> args = LogHelper.toLowerCase(Arrays.asList(arguments));
|
||||
|
||||
for(String arg : arguments) {
|
||||
args.add(arg.toLowerCase());
|
||||
if(!validArguments.containsAll(args)) {
|
||||
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + LogHelper.join(validArguments, ", ")));
|
||||
} else {
|
||||
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\");",
|
||||
LogHelper.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"));
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStacks;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
|
||||
Reference in new issue
Block a user