Add Botanical Addons support

This commit is contained in:
yrsegal 2016-01-31 12:36:58 -05:00
parent b4b50c6d60
commit 2aa238a9eb
8 changed files with 261 additions and 0 deletions

View File

@ -22,6 +22,7 @@ Supported Mods
- Applied Energistics 2
- Auracascade
- Botania
- Botanical Addons
- Chisel
- ExNihilo
- ExtendedWorkbench

Binary file not shown.

View File

@ -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());

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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"));
}
}
}

View File

@ -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<RecipeTreeCrafting> {
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<RecipeTreeCrafting> recipes = new LinkedList<RecipeTreeCrafting>();
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<RecipeTreeCrafting> {
public Remove(List<RecipeTreeCrafting> recipes) {
super(DendricSuffuser.name, ShadowFoxAPI.treeRecipes, recipes);
}
@Override
public String getRecipeInfo(RecipeTreeCrafting recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
}

View File

@ -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<IIridescentSaplingVariant> {
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<IIridescentSaplingVariant> recipes = new LinkedList<IIridescentSaplingVariant>();
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<IIridescentSaplingVariant> {
public Remove(List<IIridescentSaplingVariant> recipes) {
super(IridescentTree.name, ShadowFoxAPI.treeVariants, recipes);
}
@Override
public String getRecipeInfo(IIridescentSaplingVariant recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.getAcceptableSoils().get(0)));
}
}
}