diff --git a/README.md b/README.md index f9d1c36..0edca36 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Supported Mods - Applied Energistics 2 - Auracascade - Botania +- Botanical Addons - Chisel - ExNihilo - ExtendedWorkbench diff --git a/libs/BotanicalAddons-r0.1.20-0-deobf.jar b/libs/BotanicalAddons-r0.1.20-0-deobf.jar new file mode 100644 index 0000000..28462ee Binary files /dev/null and b/libs/BotanicalAddons-r0.1.20-0-deobf.jar differ diff --git a/src/main/java/modtweaker2/Commands.java b/src/main/java/modtweaker2/Commands.java index 792b04d..57a802b 100644 --- a/src/main/java/modtweaker2/Commands.java +++ b/src/main/java/modtweaker2/Commands.java @@ -12,6 +12,7 @@ import modtweaker2.mods.botania.commands.BotaniaOrechidLogger; import modtweaker2.mods.botania.lexicon.commands.LexiconCategoryLogger; import modtweaker2.mods.botania.lexicon.commands.LexiconKnowledgeTypesLogger; import modtweaker2.mods.botania.lexicon.commands.LexiconPageLogger; +import modtweaker2.mods.botanicaladdons.commands.BotanicalAddonsDendricLogger; import modtweaker2.mods.chisel.commands.ChiselGroupLogger; import modtweaker2.mods.chisel.commands.ChiselVariationLogger; import modtweaker2.mods.exnihilo.commands.ExNihiloLogger; @@ -58,6 +59,10 @@ public class Commands { MineTweakerAPI.server.addMineTweakerCommand("botania", new String[] { "/minetweaker botania [HANDLER]", " Outputs a list of all Botania recipes." }, new BotaniaLogger()); } + if (TweakerPlugin.isLoaded("shadowfox_botany")) { + MineTweakerAPI.server.addMineTweakerCommand("treeCrafting", new String[] { "/minetweaker treeCrafting", " Outputs a list of all Botanical Addons Tree Crafting recipes." }, new BotanicalAddonsDendricLogger()); + } + if (TweakerPlugin.isLoaded("chisel")) { MineTweakerAPI.server.addMineTweakerCommand("chiselGroups", new String[] { "/minetweaker chiselGroups", " Outputs a list of chisel groups" }, new ChiselGroupLogger()); MineTweakerAPI.server.addMineTweakerCommand("chiselVariations", new String[] { "/minetweaker chiselVariations", "/minetweaker chiselVariations [GROUP]", " Outputs a list of chisel variations" }, new ChiselVariationLogger()); diff --git a/src/main/java/modtweaker2/ModTweaker2.java b/src/main/java/modtweaker2/ModTweaker2.java index e15a7bd..710c7f7 100644 --- a/src/main/java/modtweaker2/ModTweaker2.java +++ b/src/main/java/modtweaker2/ModTweaker2.java @@ -9,6 +9,7 @@ import minetweaker.util.IEventHandler; import modtweaker2.mods.appeng.AppliedEnergistics; import modtweaker2.mods.auracascade.AuraCascade; import modtweaker2.mods.botania.Botania; +import modtweaker2.mods.botanicaladdons.BotanicalAddons; import modtweaker2.mods.chisel.Chisel; import modtweaker2.mods.exnihilo.ExNihilo; import modtweaker2.mods.extendedworkbench.ExtendedWorkbench; @@ -65,6 +66,7 @@ public class ModTweaker2 { logger.info("Starting Initialization for " + ModProps.modid); TweakerPlugin.register("appliedenergistics2-core", AppliedEnergistics.class); TweakerPlugin.register("Botania", Botania.class); + TweakerPlugin.register("shadowfox_botany", BotanicalAddons.class); TweakerPlugin.register("exnihilo", ExNihilo.class); TweakerPlugin.register("extendedWorkbench", ExtendedWorkbench.class); TweakerPlugin.register("factorization", Factorization.class); diff --git a/src/main/java/modtweaker2/mods/botanicaladdons/BotanicalAddons.java b/src/main/java/modtweaker2/mods/botanicaladdons/BotanicalAddons.java new file mode 100644 index 0000000..2ec79cd --- /dev/null +++ b/src/main/java/modtweaker2/mods/botanicaladdons/BotanicalAddons.java @@ -0,0 +1,12 @@ +package modtweaker2.mods.botanicaladdons; + +import minetweaker.MineTweakerAPI; +import modtweaker2.mods.botanicaladdons.handlers.DendricSuffuser; +import modtweaker2.mods.botanicaladdons.handlers.IridescentTree; + +public class BotanicalAddons { + public BotanicalAddons() { + MineTweakerAPI.registerClass(DendricSuffuser.class); + MineTweakerAPI.registerClass(IridescentTree.class); + } +} diff --git a/src/main/java/modtweaker2/mods/botanicaladdons/commands/BotanicalAddonsDendricLogger.java b/src/main/java/modtweaker2/mods/botanicaladdons/commands/BotanicalAddonsDendricLogger.java new file mode 100644 index 0000000..bda7833 --- /dev/null +++ b/src/main/java/modtweaker2/mods/botanicaladdons/commands/BotanicalAddonsDendricLogger.java @@ -0,0 +1,29 @@ +package modtweaker2.mods.botanicaladdons.commands; + +import minetweaker.MineTweakerAPI; +import minetweaker.MineTweakerImplementationAPI; +import minetweaker.api.player.IPlayer; +import minetweaker.api.server.ICommandFunction; +import modtweaker2.helpers.LogHelper; +import ninja.shadowfox.shadowfox_botany.api.ShadowFoxAPI; +import ninja.shadowfox.shadowfox_botany.api.recipe.RecipeTreeCrafting; + +public class BotanicalAddonsDendricLogger implements ICommandFunction{ + + @Override + public void execute(String[] arguments, IPlayer player) { + System.out.println("Recipes: " + ShadowFoxAPI.treeRecipes.size()); + for (RecipeTreeCrafting recipe : ShadowFoxAPI.treeRecipes) { + MineTweakerAPI.logCommand(String.format("mods.botanicaladdons.DendricSuffuser.addRecipe(%s, %s, %s, %s);", + LogHelper.getStackDescription(recipe.getOutput()), + recipe.getManaUsage(), + recipe.getThrottle(), + LogHelper.getListDescription(recipe.getInputs()) + )); + } + + 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/botanicaladdons/handlers/DendricSuffuser.java b/src/main/java/modtweaker2/mods/botanicaladdons/handlers/DendricSuffuser.java new file mode 100644 index 0000000..ca84650 --- /dev/null +++ b/src/main/java/modtweaker2/mods/botanicaladdons/handlers/DendricSuffuser.java @@ -0,0 +1,93 @@ +package modtweaker2.mods.botanicaladdons.handlers; + + +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemStack; +import modtweaker2.helpers.InputHelper; +import modtweaker2.helpers.LogHelper; +import modtweaker2.utils.BaseListAddition; +import modtweaker2.utils.BaseListRemoval; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import ninja.shadowfox.shadowfox_botany.api.ShadowFoxAPI; +import ninja.shadowfox.shadowfox_botany.api.recipe.RecipeTreeCrafting; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +import java.util.LinkedList; +import java.util.List; + +import static modtweaker2.helpers.InputHelper.toIItemStack; +import static modtweaker2.helpers.InputHelper.toObjects; +import static modtweaker2.helpers.StackHelper.matches; + +@ZenClass("mods.botanicaladdons.DendricSuffuser") +public class DendricSuffuser { + + protected static final String name = "Botanical Addons Dendric Suffuser"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void addRecipe(IItemStack blockOutput, int mana, int throttle, IIngredient[] input) { + Object output = InputHelper.toObject(blockOutput); + if(output == null || !(output instanceof ItemStack) || !InputHelper.isABlock((ItemStack)output)) { + LogHelper.logError("Output must be a block."); + return; + } + MineTweakerAPI.apply(new Add(new RecipeTreeCrafting(mana, Block.getBlockFromItem(((ItemStack)output).getItem()), + ((ItemStack)output).getItemDamage(), throttle, toObjects(input)))); + } + + @ZenMethod + public static void addRecipe(IItemStack blockOutput, int mana, IIngredient[] input) { + addRecipe(blockOutput, mana, -1, input); + } + + private static class Add extends BaseListAddition { + public Add(RecipeTreeCrafting recipe) { + super(DendricSuffuser.name, ShadowFoxAPI.treeRecipes); + + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(RecipeTreeCrafting recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IItemStack output) { + // Get list of existing recipes, matching with parameter + List recipes = new LinkedList(); + + for (RecipeTreeCrafting r : ShadowFoxAPI.treeRecipes) { + if (r != null && r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) { + recipes.add(r); + } + } + + // Check if we found the recipes and apply the action + if(!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", DendricSuffuser.name, output.toString())); + } + } + + private static class Remove extends BaseListRemoval { + public Remove(List recipes) { + super(DendricSuffuser.name, ShadowFoxAPI.treeRecipes, recipes); + } + + @Override + public String getRecipeInfo(RecipeTreeCrafting recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } +} + diff --git a/src/main/java/modtweaker2/mods/botanicaladdons/handlers/IridescentTree.java b/src/main/java/modtweaker2/mods/botanicaladdons/handlers/IridescentTree.java new file mode 100644 index 0000000..7c168d4 --- /dev/null +++ b/src/main/java/modtweaker2/mods/botanicaladdons/handlers/IridescentTree.java @@ -0,0 +1,119 @@ +package modtweaker2.mods.botanicaladdons.handlers; + + +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IItemStack; +import modtweaker2.helpers.InputHelper; +import modtweaker2.helpers.LogHelper; +import modtweaker2.utils.BaseListAddition; +import modtweaker2.utils.BaseListRemoval; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import ninja.shadowfox.shadowfox_botany.api.ShadowFoxAPI; +import ninja.shadowfox.shadowfox_botany.api.trees.IIridescentSaplingVariant; +import ninja.shadowfox.shadowfox_botany.api.trees.IridescentSaplingBaseVariant; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +import java.util.LinkedList; +import java.util.List; + +@ZenClass("mods.botanicaladdons.IridescentTree") +public class IridescentTree { + + protected static final String name = "Botanical Addons Iridescent Tree"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves, int metaMin, int metaMax, int metaShift) { + Object soil = InputHelper.toObject(blockSoil); + Object wood = InputHelper.toObject(blockWood); + Object leaves = InputHelper.toObject(blockLeaves); + if (soil == null || !(soil instanceof ItemStack) || !InputHelper.isABlock((ItemStack)soil)) { + LogHelper.logError("Soil must be a block."); + return; + } + else if (wood == null || !(wood instanceof ItemStack) || !InputHelper.isABlock((ItemStack)wood)) { + LogHelper.logError("Wood must be a block."); + return; + } + else if(leaves == null || !(leaves instanceof ItemStack) || !InputHelper.isABlock((ItemStack)leaves)) { + LogHelper.logError("Leaves must be a block."); + return; + } + Block soilBlock = Block.getBlockFromItem(((ItemStack)soil).getItem()); + Block woodBlock = Block.getBlockFromItem(((ItemStack)wood).getItem()); + Block leavesBlock = Block.getBlockFromItem(((ItemStack)leaves).getItem()); + MineTweakerAPI.apply(new Add(new IridescentSaplingBaseVariant(soilBlock, woodBlock, leavesBlock, metaMin, metaMax, metaShift))); + } + + @ZenMethod + public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves, int metaMin, int metaMax) { + addVariant(blockSoil, blockWood, blockLeaves, metaMin, metaMax, 0); + } + + @ZenMethod + public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves, int meta) { + addVariant(blockSoil, blockWood, blockLeaves, meta, meta, 0); + } + + @ZenMethod + public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves) { + addVariant(blockSoil, blockWood, blockLeaves, 0, 15, 0); + } + + private static class Add extends BaseListAddition { + public Add(IIridescentSaplingVariant recipe) { + super(IridescentTree.name, ShadowFoxAPI.treeVariants); + + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(IIridescentSaplingVariant recipe) { + return LogHelper.getStackDescription(new ItemStack(recipe.getAcceptableSoils().get(0))); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IItemStack blockSoil) { + // Get list of existing recipes, matching with parameter + + Object soil = InputHelper.toObject(blockSoil); + if (soil == null || !(soil instanceof ItemStack) || !InputHelper.isABlock((ItemStack)soil)) { + LogHelper.logError("Soil must be a block."); + return; + } + Block soilBlock = Block.getBlockFromItem(((ItemStack)soil).getItem()); + + List recipes = new LinkedList(); + + for (IIridescentSaplingVariant r : ShadowFoxAPI.treeVariants) { + if (r != null && r instanceof IridescentSaplingBaseVariant && r.getAcceptableSoils().get(0) == soilBlock) { + recipes.add(r); + } + } + + // Check if we found the recipes and apply the action + if(!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", IridescentTree.name, soilBlock.toString())); + } + } + + private static class Remove extends BaseListRemoval { + public Remove(List recipes) { + super(IridescentTree.name, ShadowFoxAPI.treeVariants, recipes); + } + + @Override + public String getRecipeInfo(IIridescentSaplingVariant recipe) { + return LogHelper.getStackDescription(new ItemStack(recipe.getAcceptableSoils().get(0))); + } + } +} +