From 6cbc1ff1025ef4ca815934455df691a59670c48a Mon Sep 17 00:00:00 2001 From: Zixxl Date: Mon, 27 Jul 2015 08:53:33 +0200 Subject: [PATCH 1/3] Removed unused import --- src/main/java/modtweaker2/Commands.java | 2 + .../mods/thaumcraft/Thaumcraft.java | 1 - .../thaumcraft/commands/ThaumcraftLogger.java | 61 +++++++++++++++++++ .../mods/thaumcraft/handlers/Arcane.java | 16 +++++ .../mods/thaumcraft/handlers/Aspects.java | 17 +++--- .../mods/thaumcraft/handlers/Crucible.java | 46 ++++++++++++-- .../mods/thaumcraft/handlers/Infusion.java | 4 ++ .../mods/thaumcraft/handlers/Test.java | 15 +++++ .../commands/ThermalExpansionLogger.java | 2 +- .../thermalexpansion/handlers/Insolator.java | 30 +++++---- 10 files changed, 166 insertions(+), 28 deletions(-) create mode 100644 src/main/java/modtweaker2/mods/thaumcraft/commands/ThaumcraftLogger.java create mode 100644 src/main/java/modtweaker2/mods/thaumcraft/handlers/Test.java diff --git a/src/main/java/modtweaker2/Commands.java b/src/main/java/modtweaker2/Commands.java index b352c73..8318bbc 100644 --- a/src/main/java/modtweaker2/Commands.java +++ b/src/main/java/modtweaker2/Commands.java @@ -22,6 +22,7 @@ import modtweaker2.mods.railcraft.commands.RailcraftLogger; import modtweaker2.mods.tconstruct.MaterialLogger; import modtweaker2.mods.tconstruct.commands.TConstructLogger; import modtweaker2.mods.thaumcraft.commands.AspectLogger; +import modtweaker2.mods.thaumcraft.commands.ThaumcraftLogger; import modtweaker2.mods.thaumcraft.research.commands.ResearchLogger; import modtweaker2.mods.thermalexpansion.commands.ThermalExpansionLogger; import modtweaker2.utils.TweakerPlugin; @@ -52,6 +53,7 @@ public class Commands { if (TweakerPlugin.isLoaded("Thaumcraft")) { MineTweakerAPI.server.addMineTweakerCommand("research", new String[] { "/minetweaker research", "/minetweaker research [CATEGORY]", " Outputs a list of all category names in the game to the minetweaker log," + " or outputs a list of all research keys in a category to the log." }, new ResearchLogger()); MineTweakerAPI.server.addMineTweakerCommand("aspectList", new String[] { "/minetweaker aspectList", " Outputs a list of all aspects registered to entities and items" }, new AspectLogger()); + MineTweakerAPI.server.addMineTweakerCommand("thaumcraft", new String[] { "/minetweaker thaumcraft [FILTER]", "Outputs a list of all Thaumcraft recipes."}, new ThaumcraftLogger()); } if (TweakerPlugin.isLoaded("TConstruct")) { diff --git a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java index 1425a46..01eb419 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java @@ -8,7 +8,6 @@ import modtweaker2.mods.thaumcraft.handlers.Crucible; import modtweaker2.mods.thaumcraft.handlers.Infusion; import modtweaker2.mods.thaumcraft.handlers.Loot; import modtweaker2.mods.thaumcraft.handlers.Research; -import modtweaker2.mods.thaumcraft.handlers.Test; import modtweaker2.mods.thaumcraft.handlers.Warp; public class Thaumcraft { diff --git a/src/main/java/modtweaker2/mods/thaumcraft/commands/ThaumcraftLogger.java b/src/main/java/modtweaker2/mods/thaumcraft/commands/ThaumcraftLogger.java new file mode 100644 index 0000000..0565e14 --- /dev/null +++ b/src/main/java/modtweaker2/mods/thaumcraft/commands/ThaumcraftLogger.java @@ -0,0 +1,61 @@ +package modtweaker2.mods.thaumcraft.commands; + +import java.util.Arrays; +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.LogHelper; +import modtweaker2.helpers.StringHelper; +import thaumcraft.api.ThaumcraftApi; +import thaumcraft.api.crafting.CrucibleRecipe; +import thaumcraft.api.crafting.IArcaneRecipe; + +public class ThaumcraftLogger implements ICommandFunction { + + private static final List validArguments = new LinkedList(); + + static { + validArguments.add("crucible"); + } + + @Override + public void execute(String[] arguments, IPlayer player) { + List args = StringHelper.toLowerCase(Arrays.asList(arguments)); + + if(!validArguments.containsAll(args)) { + if(player != null) { + player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); + } + } else { + if(args.isEmpty() || args.contains("arcane")) { + for(Object o : ThaumcraftApi.getCraftingRecipes()) { + if(o instanceof IArcaneRecipe) { + + } + } + } + + if(args.isEmpty() || args.contains("crucible")) { + for(Object o : ThaumcraftApi.getCraftingRecipes()) { + if(o instanceof CrucibleRecipe) { + CrucibleRecipe recipe = (CrucibleRecipe)o; + MineTweakerAPI.logCommand(String.format("mods.thaumcraft.Crucible(%s, %s, %s, %s);", + recipe.key, + LogHelper.getStackDescription(recipe.getRecipeOutput()), + LogHelper.getStackDescription(recipe.catalyst), + LogHelper.getStackDescription(recipe.aspects))); + } + } + } + + + 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/thaumcraft/handlers/Arcane.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java index 09d35df..a48ee6b 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java @@ -14,6 +14,8 @@ import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.LogHelper; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; +import modtweaker2.mods.thaumcraft.aspect.AspectStack; +import modtweaker2.mods.thaumcraft.aspect.IAspectStack; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; import net.minecraft.item.ItemStack; @@ -31,17 +33,30 @@ public class Arcane { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @ZenMethod + public static void addShaped(String key, IItemStack output, IAspectStack[] aspects, IIngredient[][] ingredients) { + MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), AspectStack.join(ThaumcraftHelper.toStacks(aspects)), toShapedObjects(ingredients)))); + } + + @Deprecated @ZenMethod public static void addShaped(String key, IItemStack output, String aspects, IIngredient[][] ingredients) { MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients)))); } + @ZenMethod + public static void addShapeless(String key, IItemStack output, IAspectStack[] aspects, IIngredient[] ingredients) { + MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), AspectStack.join(ThaumcraftHelper.toStacks(aspects)), toObjects(ingredients)))); + } + + @Deprecated @ZenMethod public static void addShapeless(String key, IItemStack output, String aspects, IIngredient[] ingredients) { MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients)))); } private static class Add extends BaseListAddition { + @SuppressWarnings("unchecked") public Add(IArcaneRecipe recipe) { super(Arcane.name, ThaumcraftApi.getCraftingRecipes()); recipes.add(recipe); @@ -82,6 +97,7 @@ public class Arcane { } private static class Remove extends BaseListRemoval { + @SuppressWarnings("unchecked") public Remove(List recipes) { super(Arcane.name, ThaumcraftApi.getCraftingRecipes(), recipes); } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java index ad11a57..3bdc531 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java @@ -21,14 +21,12 @@ public class Aspects { /** Add/Remove/Set Aspects for items **/ @ZenMethod public static void add(IItemStack stack, String aspects) { - - MineTweakerAPI.apply(new Add(toStack(stack), aspects, false)); + MineTweakerAPI.apply(new Add(toStack(stack), aspects, false)); } @ZenMethod public static void set(IItemStack stack, String aspects) { - - MineTweakerAPI.apply(new Add(toStack(stack), aspects, true)); + MineTweakerAPI.apply(new Add(toStack(stack), aspects, true)); } // Adds or sets Aspects @@ -77,8 +75,7 @@ public class Aspects { @ZenMethod public static void remove(IItemStack stack, String aspects) { - - MineTweakerAPI.apply(new Remove(toStack(stack), aspects)); + MineTweakerAPI.apply(new Remove(toStack(stack), aspects)); } private static class Remove extends BaseUndoable { @@ -138,7 +135,7 @@ public class Aspects { return; } - MineTweakerAPI.apply(new AddEntity(entityName, aspects, true)); + MineTweakerAPI.apply(new AddEntity(entityName, aspects, true)); } // Adds or sets Aspects @@ -182,7 +179,7 @@ public class Aspects { } } - // //////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void removeEntity(String entityName, String aspects) { @@ -190,8 +187,8 @@ public class Aspects { MineTweakerAPI.getLogger().logError("No such entity " + entityName); return; } - - MineTweakerAPI.apply(new RemoveEntity(entityName, aspects)); + + MineTweakerAPI.apply(new RemoveEntity(entityName, aspects)); } private static class RemoveEntity extends BaseUndoable { diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java index f362ab0..32d8de9 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java @@ -2,9 +2,11 @@ package modtweaker2.mods.thaumcraft.handlers; import static modtweaker2.helpers.InputHelper.toIItemStack; import static modtweaker2.helpers.InputHelper.toObject; +import static modtweaker2.helpers.InputHelper.toObjects; import static modtweaker2.helpers.InputHelper.toStack; import static modtweaker2.helpers.StackHelper.matches; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -13,8 +15,11 @@ import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.LogHelper; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; +import modtweaker2.mods.thaumcraft.aspect.AspectStack; +import modtweaker2.mods.thaumcraft.aspect.IAspectStack; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; +import scala.actors.threadpool.Arrays; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import thaumcraft.api.ThaumcraftApi; @@ -25,13 +30,42 @@ public class Crucible { public static final String name = "Thaumcraft Crucible"; + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @Deprecated + @ZenMethod + public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) { + MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects)))); + } + + @ZenMethod + public static void addRecipe(String key, IItemStack itemOutput, IIngredient itemInput, IAspectStack[] aspectInput) { + addRecipe(key, itemOutput, new IIngredient[] {itemInput}, aspectInput); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) @ZenMethod - public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) { - MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects)))); + public static void addRecipe(String key, IItemStack itemOutput, IIngredient[] itemInput, IAspectStack[] aspectInput) { + if(key == null || itemOutput == null || itemInput == null || itemInput.length == 0 || aspectInput == null || aspectInput.length == 0) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } + + Object input; + + if(itemInput.length == 1) { + input = toObject(itemInput[0]); + } else { + input = new ArrayList(Arrays.asList(toObjects(itemInput))); + } + + MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(itemOutput), input, AspectStack.join(ThaumcraftHelper.toStacks(aspectInput))))); } private static class Add extends BaseListAddition { - public Add(CrucibleRecipe recipe) { + + @SuppressWarnings("unchecked") + public Add(CrucibleRecipe recipe) { super(Crucible.name, ThaumcraftApi.getCraftingRecipes()); recipes.add(recipe); } @@ -42,7 +76,7 @@ public class Crucible { } } - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void removeRecipe(IIngredient output) { @@ -65,7 +99,9 @@ public class Crucible { } private static class Remove extends BaseListRemoval { - public Remove(List recipes) { + + @SuppressWarnings("unchecked") + public Remove(List recipes) { super(Crucible.name, ThaumcraftApi.getCraftingRecipes(), recipes); } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java index f242d4e..d33f4e3 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java @@ -49,6 +49,7 @@ public class Infusion { } private static class Add extends BaseListAddition { + @SuppressWarnings("unchecked") public Add(InfusionRecipe recipe) { super(Infusion.name, ThaumcraftApi.getCraftingRecipes()); recipes.add(recipe); @@ -65,6 +66,7 @@ public class Infusion { } private static class AddEnchant extends BaseListAddition { + @SuppressWarnings("unchecked") public AddEnchant(InfusionEnchantmentRecipe inp) { super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes()); recipes.add(inp); @@ -120,6 +122,7 @@ public class Infusion { } private static class Remove extends BaseListRemoval { + @SuppressWarnings("unchecked") public Remove(List recipes) { super(Infusion.name, ThaumcraftApi.getCraftingRecipes(), recipes); } @@ -138,6 +141,7 @@ public class Infusion { } private static class RemoveEnchant extends BaseListRemoval { + @SuppressWarnings("unchecked") public RemoveEnchant(List recipes) { super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes(), recipes); } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Test.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Test.java new file mode 100644 index 0000000..e0c88fd --- /dev/null +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Test.java @@ -0,0 +1,15 @@ +package modtweaker2.mods.thaumcraft.handlers; + +import minetweaker.api.item.IIngredient; +import modtweaker2.mods.thaumcraft.aspect.IAspectStack; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +@ZenClass("mods.thaumcraft.Test") +public class Test { + @ZenMethod + public static void getAspect(IAspectStack aspectStack, IIngredient ingredient) { + System.out.println(aspectStack.getName()); + + } +} diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java b/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java index ac90c1c..c8e4299 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java @@ -68,7 +68,7 @@ public class ThermalExpansionLogger implements ICommandFunction { if(args.isEmpty() || args.contains("insolator")) { for(RecipeInsolator recipe : InsolatorManager.getRecipeList()) { if(recipe.getSecondaryOutput() != null) { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Insolator.addRecipe(%d, %s, %s, %s, %s, %d);", + MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Insolator.addRecipe(%d, %s, %s, %s, %s %% %d);", recipe.getEnergy(), LogHelper.getStackDescription(recipe.getPrimaryInput()), LogHelper.getStackDescription(recipe.getSecondaryInput()), diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java index 7c49d08..7f6d6b7 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java @@ -11,6 +11,7 @@ import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; +import minetweaker.api.item.WeightedItemStack; import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; @@ -30,24 +31,31 @@ public class Insolator { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod - public static void addRecipe(int energy, IItemStack primaryInput, IItemStack secondaryInput, IItemStack primaryOutput, @Optional IItemStack secondaryOutput, @Optional int secondaryChance) { - if(primaryInput == null || secondaryInput == null || primaryOutput == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } - - if(InsolatorManager.recipeExists(toStack(primaryInput), toStack(secondaryInput))) { + public static void addRecipe(int energy, IItemStack primaryInput, IItemStack secondaryInput, IItemStack primaryOutput, @Optional WeightedItemStack secondaryOutput) { + if(primaryInput == null || secondaryInput == null || primaryOutput == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } + + if(InsolatorManager.recipeExists(toStack(primaryInput), toStack(secondaryInput))) { LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", name, primaryInput.toString(), secondaryInput.toString())); return; - } - - RecipeInsolator recipe = ReflectionHelper.getInstance(ThermalHelper.insolatorRecipe, toStack(primaryInput), toStack(secondaryInput), toStack(primaryOutput), toStack(secondaryOutput), secondaryChance, energy); - + } + + RecipeInsolator recipe = ReflectionHelper.getInstance(ThermalHelper.insolatorRecipe, toStack(primaryInput), toStack(secondaryInput), toStack(primaryOutput), toStack(secondaryOutput.getStack()), (int)(secondaryOutput != null ? secondaryOutput.getPercent() : 0), energy); + if(recipe != null) { MineTweakerAPI.apply(new Add(recipe)); } else { LogHelper.logError(String.format("Error while creating instance for %s recipe.", name)); } + + } + + @Deprecated + @ZenMethod + public static void addRecipe(int energy, IItemStack primaryInput, IItemStack secondaryInput, IItemStack primaryOutput, @Optional IItemStack secondaryOutput, @Optional int secondaryChance) { + addRecipe(energy, primaryInput, secondaryInput, primaryOutput, secondaryOutput != null ? secondaryOutput.weight(secondaryChance) : null); } private static class Add extends BaseListAddition { From e9cdbfba922d48242f027f30b2ea71ecc7a3a735 Mon Sep 17 00:00:00 2001 From: Zixxl Date: Mon, 27 Jul 2015 08:56:20 +0200 Subject: [PATCH 2/3] Revert "Removed unused import" This reverts commit 6cbc1ff1025ef4ca815934455df691a59670c48a. --- src/main/java/modtweaker2/Commands.java | 2 - .../mods/thaumcraft/Thaumcraft.java | 1 + .../thaumcraft/commands/ThaumcraftLogger.java | 61 ------------------- .../mods/thaumcraft/handlers/Arcane.java | 16 ----- .../mods/thaumcraft/handlers/Aspects.java | 17 +++--- .../mods/thaumcraft/handlers/Crucible.java | 46 ++------------ .../mods/thaumcraft/handlers/Infusion.java | 4 -- .../mods/thaumcraft/handlers/Test.java | 15 ----- .../commands/ThermalExpansionLogger.java | 2 +- .../thermalexpansion/handlers/Insolator.java | 30 ++++----- 10 files changed, 28 insertions(+), 166 deletions(-) delete mode 100644 src/main/java/modtweaker2/mods/thaumcraft/commands/ThaumcraftLogger.java delete mode 100644 src/main/java/modtweaker2/mods/thaumcraft/handlers/Test.java diff --git a/src/main/java/modtweaker2/Commands.java b/src/main/java/modtweaker2/Commands.java index 8318bbc..b352c73 100644 --- a/src/main/java/modtweaker2/Commands.java +++ b/src/main/java/modtweaker2/Commands.java @@ -22,7 +22,6 @@ import modtweaker2.mods.railcraft.commands.RailcraftLogger; import modtweaker2.mods.tconstruct.MaterialLogger; import modtweaker2.mods.tconstruct.commands.TConstructLogger; import modtweaker2.mods.thaumcraft.commands.AspectLogger; -import modtweaker2.mods.thaumcraft.commands.ThaumcraftLogger; import modtweaker2.mods.thaumcraft.research.commands.ResearchLogger; import modtweaker2.mods.thermalexpansion.commands.ThermalExpansionLogger; import modtweaker2.utils.TweakerPlugin; @@ -53,7 +52,6 @@ public class Commands { if (TweakerPlugin.isLoaded("Thaumcraft")) { MineTweakerAPI.server.addMineTweakerCommand("research", new String[] { "/minetweaker research", "/minetweaker research [CATEGORY]", " Outputs a list of all category names in the game to the minetweaker log," + " or outputs a list of all research keys in a category to the log." }, new ResearchLogger()); MineTweakerAPI.server.addMineTweakerCommand("aspectList", new String[] { "/minetweaker aspectList", " Outputs a list of all aspects registered to entities and items" }, new AspectLogger()); - MineTweakerAPI.server.addMineTweakerCommand("thaumcraft", new String[] { "/minetweaker thaumcraft [FILTER]", "Outputs a list of all Thaumcraft recipes."}, new ThaumcraftLogger()); } if (TweakerPlugin.isLoaded("TConstruct")) { diff --git a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java index 01eb419..1425a46 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java @@ -8,6 +8,7 @@ import modtweaker2.mods.thaumcraft.handlers.Crucible; import modtweaker2.mods.thaumcraft.handlers.Infusion; import modtweaker2.mods.thaumcraft.handlers.Loot; import modtweaker2.mods.thaumcraft.handlers.Research; +import modtweaker2.mods.thaumcraft.handlers.Test; import modtweaker2.mods.thaumcraft.handlers.Warp; public class Thaumcraft { diff --git a/src/main/java/modtweaker2/mods/thaumcraft/commands/ThaumcraftLogger.java b/src/main/java/modtweaker2/mods/thaumcraft/commands/ThaumcraftLogger.java deleted file mode 100644 index 0565e14..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/commands/ThaumcraftLogger.java +++ /dev/null @@ -1,61 +0,0 @@ -package modtweaker2.mods.thaumcraft.commands; - -import java.util.Arrays; -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.LogHelper; -import modtweaker2.helpers.StringHelper; -import thaumcraft.api.ThaumcraftApi; -import thaumcraft.api.crafting.CrucibleRecipe; -import thaumcraft.api.crafting.IArcaneRecipe; - -public class ThaumcraftLogger implements ICommandFunction { - - private static final List validArguments = new LinkedList(); - - static { - validArguments.add("crucible"); - } - - @Override - public void execute(String[] arguments, IPlayer player) { - List args = StringHelper.toLowerCase(Arrays.asList(arguments)); - - if(!validArguments.containsAll(args)) { - if(player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); - } - } else { - if(args.isEmpty() || args.contains("arcane")) { - for(Object o : ThaumcraftApi.getCraftingRecipes()) { - if(o instanceof IArcaneRecipe) { - - } - } - } - - if(args.isEmpty() || args.contains("crucible")) { - for(Object o : ThaumcraftApi.getCraftingRecipes()) { - if(o instanceof CrucibleRecipe) { - CrucibleRecipe recipe = (CrucibleRecipe)o; - MineTweakerAPI.logCommand(String.format("mods.thaumcraft.Crucible(%s, %s, %s, %s);", - recipe.key, - LogHelper.getStackDescription(recipe.getRecipeOutput()), - LogHelper.getStackDescription(recipe.catalyst), - LogHelper.getStackDescription(recipe.aspects))); - } - } - } - - - 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/thaumcraft/handlers/Arcane.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java index a48ee6b..09d35df 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java @@ -14,8 +14,6 @@ import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.LogHelper; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import modtweaker2.mods.thaumcraft.aspect.AspectStack; -import modtweaker2.mods.thaumcraft.aspect.IAspectStack; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; import net.minecraft.item.ItemStack; @@ -33,30 +31,17 @@ public class Arcane { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void addShaped(String key, IItemStack output, IAspectStack[] aspects, IIngredient[][] ingredients) { - MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), AspectStack.join(ThaumcraftHelper.toStacks(aspects)), toShapedObjects(ingredients)))); - } - - @Deprecated @ZenMethod public static void addShaped(String key, IItemStack output, String aspects, IIngredient[][] ingredients) { MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients)))); } - @ZenMethod - public static void addShapeless(String key, IItemStack output, IAspectStack[] aspects, IIngredient[] ingredients) { - MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), AspectStack.join(ThaumcraftHelper.toStacks(aspects)), toObjects(ingredients)))); - } - - @Deprecated @ZenMethod public static void addShapeless(String key, IItemStack output, String aspects, IIngredient[] ingredients) { MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients)))); } private static class Add extends BaseListAddition { - @SuppressWarnings("unchecked") public Add(IArcaneRecipe recipe) { super(Arcane.name, ThaumcraftApi.getCraftingRecipes()); recipes.add(recipe); @@ -97,7 +82,6 @@ public class Arcane { } private static class Remove extends BaseListRemoval { - @SuppressWarnings("unchecked") public Remove(List recipes) { super(Arcane.name, ThaumcraftApi.getCraftingRecipes(), recipes); } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java index 3bdc531..ad11a57 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java @@ -21,12 +21,14 @@ public class Aspects { /** Add/Remove/Set Aspects for items **/ @ZenMethod public static void add(IItemStack stack, String aspects) { - MineTweakerAPI.apply(new Add(toStack(stack), aspects, false)); + + MineTweakerAPI.apply(new Add(toStack(stack), aspects, false)); } @ZenMethod public static void set(IItemStack stack, String aspects) { - MineTweakerAPI.apply(new Add(toStack(stack), aspects, true)); + + MineTweakerAPI.apply(new Add(toStack(stack), aspects, true)); } // Adds or sets Aspects @@ -75,7 +77,8 @@ public class Aspects { @ZenMethod public static void remove(IItemStack stack, String aspects) { - MineTweakerAPI.apply(new Remove(toStack(stack), aspects)); + + MineTweakerAPI.apply(new Remove(toStack(stack), aspects)); } private static class Remove extends BaseUndoable { @@ -135,7 +138,7 @@ public class Aspects { return; } - MineTweakerAPI.apply(new AddEntity(entityName, aspects, true)); + MineTweakerAPI.apply(new AddEntity(entityName, aspects, true)); } // Adds or sets Aspects @@ -179,7 +182,7 @@ public class Aspects { } } - ////////////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////////////// @ZenMethod public static void removeEntity(String entityName, String aspects) { @@ -187,8 +190,8 @@ public class Aspects { MineTweakerAPI.getLogger().logError("No such entity " + entityName); return; } - - MineTweakerAPI.apply(new RemoveEntity(entityName, aspects)); + + MineTweakerAPI.apply(new RemoveEntity(entityName, aspects)); } private static class RemoveEntity extends BaseUndoable { diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java index 32d8de9..f362ab0 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java @@ -2,11 +2,9 @@ package modtweaker2.mods.thaumcraft.handlers; import static modtweaker2.helpers.InputHelper.toIItemStack; import static modtweaker2.helpers.InputHelper.toObject; -import static modtweaker2.helpers.InputHelper.toObjects; import static modtweaker2.helpers.InputHelper.toStack; import static modtweaker2.helpers.StackHelper.matches; -import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -15,11 +13,8 @@ import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.LogHelper; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import modtweaker2.mods.thaumcraft.aspect.AspectStack; -import modtweaker2.mods.thaumcraft.aspect.IAspectStack; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; -import scala.actors.threadpool.Arrays; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import thaumcraft.api.ThaumcraftApi; @@ -30,42 +25,13 @@ public class Crucible { public static final String name = "Thaumcraft Crucible"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @Deprecated - @ZenMethod - public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) { - MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects)))); - } - - @ZenMethod - public static void addRecipe(String key, IItemStack itemOutput, IIngredient itemInput, IAspectStack[] aspectInput) { - addRecipe(key, itemOutput, new IIngredient[] {itemInput}, aspectInput); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) @ZenMethod - public static void addRecipe(String key, IItemStack itemOutput, IIngredient[] itemInput, IAspectStack[] aspectInput) { - if(key == null || itemOutput == null || itemInput == null || itemInput.length == 0 || aspectInput == null || aspectInput.length == 0) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } - - Object input; - - if(itemInput.length == 1) { - input = toObject(itemInput[0]); - } else { - input = new ArrayList(Arrays.asList(toObjects(itemInput))); - } - - MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(itemOutput), input, AspectStack.join(ThaumcraftHelper.toStacks(aspectInput))))); + public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) { + MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects)))); } private static class Add extends BaseListAddition { - - @SuppressWarnings("unchecked") - public Add(CrucibleRecipe recipe) { + public Add(CrucibleRecipe recipe) { super(Crucible.name, ThaumcraftApi.getCraftingRecipes()); recipes.add(recipe); } @@ -76,7 +42,7 @@ public class Crucible { } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void removeRecipe(IIngredient output) { @@ -99,9 +65,7 @@ public class Crucible { } private static class Remove extends BaseListRemoval { - - @SuppressWarnings("unchecked") - public Remove(List recipes) { + public Remove(List recipes) { super(Crucible.name, ThaumcraftApi.getCraftingRecipes(), recipes); } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java index d33f4e3..f242d4e 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java @@ -49,7 +49,6 @@ public class Infusion { } private static class Add extends BaseListAddition { - @SuppressWarnings("unchecked") public Add(InfusionRecipe recipe) { super(Infusion.name, ThaumcraftApi.getCraftingRecipes()); recipes.add(recipe); @@ -66,7 +65,6 @@ public class Infusion { } private static class AddEnchant extends BaseListAddition { - @SuppressWarnings("unchecked") public AddEnchant(InfusionEnchantmentRecipe inp) { super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes()); recipes.add(inp); @@ -122,7 +120,6 @@ public class Infusion { } private static class Remove extends BaseListRemoval { - @SuppressWarnings("unchecked") public Remove(List recipes) { super(Infusion.name, ThaumcraftApi.getCraftingRecipes(), recipes); } @@ -141,7 +138,6 @@ public class Infusion { } private static class RemoveEnchant extends BaseListRemoval { - @SuppressWarnings("unchecked") public RemoveEnchant(List recipes) { super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes(), recipes); } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Test.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Test.java deleted file mode 100644 index e0c88fd..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Test.java +++ /dev/null @@ -1,15 +0,0 @@ -package modtweaker2.mods.thaumcraft.handlers; - -import minetweaker.api.item.IIngredient; -import modtweaker2.mods.thaumcraft.aspect.IAspectStack; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; - -@ZenClass("mods.thaumcraft.Test") -public class Test { - @ZenMethod - public static void getAspect(IAspectStack aspectStack, IIngredient ingredient) { - System.out.println(aspectStack.getName()); - - } -} diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java b/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java index c8e4299..ac90c1c 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java @@ -68,7 +68,7 @@ public class ThermalExpansionLogger implements ICommandFunction { if(args.isEmpty() || args.contains("insolator")) { for(RecipeInsolator recipe : InsolatorManager.getRecipeList()) { if(recipe.getSecondaryOutput() != null) { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Insolator.addRecipe(%d, %s, %s, %s, %s %% %d);", + MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Insolator.addRecipe(%d, %s, %s, %s, %s, %d);", recipe.getEnergy(), LogHelper.getStackDescription(recipe.getPrimaryInput()), LogHelper.getStackDescription(recipe.getSecondaryInput()), diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java index 7f6d6b7..7c49d08 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java @@ -11,7 +11,6 @@ import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; -import minetweaker.api.item.WeightedItemStack; import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; @@ -31,31 +30,24 @@ public class Insolator { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod - public static void addRecipe(int energy, IItemStack primaryInput, IItemStack secondaryInput, IItemStack primaryOutput, @Optional WeightedItemStack secondaryOutput) { - if(primaryInput == null || secondaryInput == null || primaryOutput == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } - - if(InsolatorManager.recipeExists(toStack(primaryInput), toStack(secondaryInput))) { + public static void addRecipe(int energy, IItemStack primaryInput, IItemStack secondaryInput, IItemStack primaryOutput, @Optional IItemStack secondaryOutput, @Optional int secondaryChance) { + if(primaryInput == null || secondaryInput == null || primaryOutput == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } + + if(InsolatorManager.recipeExists(toStack(primaryInput), toStack(secondaryInput))) { LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", name, primaryInput.toString(), secondaryInput.toString())); return; - } - - RecipeInsolator recipe = ReflectionHelper.getInstance(ThermalHelper.insolatorRecipe, toStack(primaryInput), toStack(secondaryInput), toStack(primaryOutput), toStack(secondaryOutput.getStack()), (int)(secondaryOutput != null ? secondaryOutput.getPercent() : 0), energy); - + } + + RecipeInsolator recipe = ReflectionHelper.getInstance(ThermalHelper.insolatorRecipe, toStack(primaryInput), toStack(secondaryInput), toStack(primaryOutput), toStack(secondaryOutput), secondaryChance, energy); + if(recipe != null) { MineTweakerAPI.apply(new Add(recipe)); } else { LogHelper.logError(String.format("Error while creating instance for %s recipe.", name)); } - - } - - @Deprecated - @ZenMethod - public static void addRecipe(int energy, IItemStack primaryInput, IItemStack secondaryInput, IItemStack primaryOutput, @Optional IItemStack secondaryOutput, @Optional int secondaryChance) { - addRecipe(energy, primaryInput, secondaryInput, primaryOutput, secondaryOutput != null ? secondaryOutput.weight(secondaryChance) : null); } private static class Add extends BaseListAddition { From a4b2d47f74af794f2c89f087fed2b183e2f94a1d Mon Sep 17 00:00:00 2001 From: Zixxl Date: Mon, 27 Jul 2015 08:58:47 +0200 Subject: [PATCH 3/3] Removed unused import --- src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java | 1 - src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java index 1425a46..01eb419 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java @@ -8,7 +8,6 @@ import modtweaker2.mods.thaumcraft.handlers.Crucible; import modtweaker2.mods.thaumcraft.handlers.Infusion; import modtweaker2.mods.thaumcraft.handlers.Loot; import modtweaker2.mods.thaumcraft.handlers.Research; -import modtweaker2.mods.thaumcraft.handlers.Test; import modtweaker2.mods.thaumcraft.handlers.Warp; public class Thaumcraft { diff --git a/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java b/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java index 383a597..abaadeb 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java @@ -4,12 +4,10 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import minetweaker.api.item.IItemStack; import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thaumcraft.aspect.AspectStack; import modtweaker2.mods.thaumcraft.aspect.IAspectStack; -import net.minecraft.item.ItemStack; import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.ThaumcraftApi.EntityTags; import thaumcraft.api.aspects.Aspect;