Skip to content

Commit ddd78e9

Browse files
committed
Merge pull request #302 from yrsegal/master
Add Botanical Addons support
2 parents 5c520e8 + 2aa238a commit ddd78e9

8 files changed

Lines changed: 261 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Supported Mods
2222
- Applied Energistics 2
2323
- Auracascade
2424
- Botania
25+
- Botanical Addons
2526
- Chisel
2627
- ExNihilo
2728
- ExtendedWorkbench
1.44 MB
Binary file not shown.

src/main/java/modtweaker2/Commands.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import modtweaker2.mods.botania.lexicon.commands.LexiconCategoryLogger;
1313
import modtweaker2.mods.botania.lexicon.commands.LexiconKnowledgeTypesLogger;
1414
import modtweaker2.mods.botania.lexicon.commands.LexiconPageLogger;
15+
import modtweaker2.mods.botanicaladdons.commands.BotanicalAddonsDendricLogger;
1516
import modtweaker2.mods.chisel.commands.ChiselGroupLogger;
1617
import modtweaker2.mods.chisel.commands.ChiselVariationLogger;
1718
import modtweaker2.mods.exnihilo.commands.ExNihiloLogger;
@@ -58,6 +59,10 @@ public void execute(String[] arguments, IPlayer player) {
5859
MineTweakerAPI.server.addMineTweakerCommand("botania", new String[] { "/minetweaker botania [HANDLER]", " Outputs a list of all Botania recipes." }, new BotaniaLogger());
5960
}
6061

62+
if (TweakerPlugin.isLoaded("shadowfox_botany")) {
63+
MineTweakerAPI.server.addMineTweakerCommand("treeCrafting", new String[] { "/minetweaker treeCrafting", " Outputs a list of all Botanical Addons Tree Crafting recipes." }, new BotanicalAddonsDendricLogger());
64+
}
65+
6166
if (TweakerPlugin.isLoaded("chisel")) {
6267
MineTweakerAPI.server.addMineTweakerCommand("chiselGroups", new String[] { "/minetweaker chiselGroups", " Outputs a list of chisel groups" }, new ChiselGroupLogger());
6368
MineTweakerAPI.server.addMineTweakerCommand("chiselVariations", new String[] { "/minetweaker chiselVariations", "/minetweaker chiselVariations [GROUP]", " Outputs a list of chisel variations" }, new ChiselVariationLogger());

src/main/java/modtweaker2/ModTweaker2.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import modtweaker2.mods.appeng.AppliedEnergistics;
1010
import modtweaker2.mods.auracascade.AuraCascade;
1111
import modtweaker2.mods.botania.Botania;
12+
import modtweaker2.mods.botanicaladdons.BotanicalAddons;
1213
import modtweaker2.mods.chisel.Chisel;
1314
import modtweaker2.mods.exnihilo.ExNihilo;
1415
import modtweaker2.mods.extendedworkbench.ExtendedWorkbench;
@@ -65,6 +66,7 @@ public void init(FMLInitializationEvent event) {
6566
logger.info("Starting Initialization for " + ModProps.modid);
6667
TweakerPlugin.register("appliedenergistics2-core", AppliedEnergistics.class);
6768
TweakerPlugin.register("Botania", Botania.class);
69+
TweakerPlugin.register("shadowfox_botany", BotanicalAddons.class);
6870
TweakerPlugin.register("exnihilo", ExNihilo.class);
6971
TweakerPlugin.register("extendedWorkbench", ExtendedWorkbench.class);
7072
TweakerPlugin.register("factorization", Factorization.class);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package modtweaker2.mods.botanicaladdons;
2+
3+
import minetweaker.MineTweakerAPI;
4+
import modtweaker2.mods.botanicaladdons.handlers.DendricSuffuser;
5+
import modtweaker2.mods.botanicaladdons.handlers.IridescentTree;
6+
7+
public class BotanicalAddons {
8+
public BotanicalAddons() {
9+
MineTweakerAPI.registerClass(DendricSuffuser.class);
10+
MineTweakerAPI.registerClass(IridescentTree.class);
11+
}
12+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package modtweaker2.mods.botanicaladdons.commands;
2+
3+
import minetweaker.MineTweakerAPI;
4+
import minetweaker.MineTweakerImplementationAPI;
5+
import minetweaker.api.player.IPlayer;
6+
import minetweaker.api.server.ICommandFunction;
7+
import modtweaker2.helpers.LogHelper;
8+
import ninja.shadowfox.shadowfox_botany.api.ShadowFoxAPI;
9+
import ninja.shadowfox.shadowfox_botany.api.recipe.RecipeTreeCrafting;
10+
11+
public class BotanicalAddonsDendricLogger implements ICommandFunction{
12+
13+
@Override
14+
public void execute(String[] arguments, IPlayer player) {
15+
System.out.println("Recipes: " + ShadowFoxAPI.treeRecipes.size());
16+
for (RecipeTreeCrafting recipe : ShadowFoxAPI.treeRecipes) {
17+
MineTweakerAPI.logCommand(String.format("mods.botanicaladdons.DendricSuffuser.addRecipe(%s, %s, %s, %s);",
18+
LogHelper.getStackDescription(recipe.getOutput()),
19+
recipe.getManaUsage(),
20+
recipe.getThrottle(),
21+
LogHelper.getListDescription(recipe.getInputs())
22+
));
23+
}
24+
25+
if (player != null) {
26+
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
27+
}
28+
}
29+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package modtweaker2.mods.botanicaladdons.handlers;
2+
3+
4+
import minetweaker.MineTweakerAPI;
5+
import minetweaker.api.item.IIngredient;
6+
import minetweaker.api.item.IItemStack;
7+
import modtweaker2.helpers.InputHelper;
8+
import modtweaker2.helpers.LogHelper;
9+
import modtweaker2.utils.BaseListAddition;
10+
import modtweaker2.utils.BaseListRemoval;
11+
import net.minecraft.block.Block;
12+
import net.minecraft.item.ItemStack;
13+
import ninja.shadowfox.shadowfox_botany.api.ShadowFoxAPI;
14+
import ninja.shadowfox.shadowfox_botany.api.recipe.RecipeTreeCrafting;
15+
import stanhebben.zenscript.annotations.ZenClass;
16+
import stanhebben.zenscript.annotations.ZenMethod;
17+
18+
import java.util.LinkedList;
19+
import java.util.List;
20+
21+
import static modtweaker2.helpers.InputHelper.toIItemStack;
22+
import static modtweaker2.helpers.InputHelper.toObjects;
23+
import static modtweaker2.helpers.StackHelper.matches;
24+
25+
@ZenClass("mods.botanicaladdons.DendricSuffuser")
26+
public class DendricSuffuser {
27+
28+
protected static final String name = "Botanical Addons Dendric Suffuser";
29+
30+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
31+
32+
@ZenMethod
33+
public static void addRecipe(IItemStack blockOutput, int mana, int throttle, IIngredient[] input) {
34+
Object output = InputHelper.toObject(blockOutput);
35+
if(output == null || !(output instanceof ItemStack) || !InputHelper.isABlock((ItemStack)output)) {
36+
LogHelper.logError("Output must be a block.");
37+
return;
38+
}
39+
MineTweakerAPI.apply(new Add(new RecipeTreeCrafting(mana, Block.getBlockFromItem(((ItemStack)output).getItem()),
40+
((ItemStack)output).getItemDamage(), throttle, toObjects(input))));
41+
}
42+
43+
@ZenMethod
44+
public static void addRecipe(IItemStack blockOutput, int mana, IIngredient[] input) {
45+
addRecipe(blockOutput, mana, -1, input);
46+
}
47+
48+
private static class Add extends BaseListAddition<RecipeTreeCrafting> {
49+
public Add(RecipeTreeCrafting recipe) {
50+
super(DendricSuffuser.name, ShadowFoxAPI.treeRecipes);
51+
52+
recipes.add(recipe);
53+
}
54+
55+
@Override
56+
public String getRecipeInfo(RecipeTreeCrafting recipe) {
57+
return LogHelper.getStackDescription(recipe.getOutput());
58+
}
59+
}
60+
61+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
62+
63+
@ZenMethod
64+
public static void removeRecipe(IItemStack output) {
65+
// Get list of existing recipes, matching with parameter
66+
List<RecipeTreeCrafting> recipes = new LinkedList<RecipeTreeCrafting>();
67+
68+
for (RecipeTreeCrafting r : ShadowFoxAPI.treeRecipes) {
69+
if (r != null && r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
70+
recipes.add(r);
71+
}
72+
}
73+
74+
// Check if we found the recipes and apply the action
75+
if(!recipes.isEmpty()) {
76+
MineTweakerAPI.apply(new Remove(recipes));
77+
} else {
78+
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", DendricSuffuser.name, output.toString()));
79+
}
80+
}
81+
82+
private static class Remove extends BaseListRemoval<RecipeTreeCrafting> {
83+
public Remove(List<RecipeTreeCrafting> recipes) {
84+
super(DendricSuffuser.name, ShadowFoxAPI.treeRecipes, recipes);
85+
}
86+
87+
@Override
88+
public String getRecipeInfo(RecipeTreeCrafting recipe) {
89+
return LogHelper.getStackDescription(recipe.getOutput());
90+
}
91+
}
92+
}
93+
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package modtweaker2.mods.botanicaladdons.handlers;
2+
3+
4+
import minetweaker.MineTweakerAPI;
5+
import minetweaker.api.item.IItemStack;
6+
import modtweaker2.helpers.InputHelper;
7+
import modtweaker2.helpers.LogHelper;
8+
import modtweaker2.utils.BaseListAddition;
9+
import modtweaker2.utils.BaseListRemoval;
10+
import net.minecraft.block.Block;
11+
import net.minecraft.item.ItemStack;
12+
import ninja.shadowfox.shadowfox_botany.api.ShadowFoxAPI;
13+
import ninja.shadowfox.shadowfox_botany.api.trees.IIridescentSaplingVariant;
14+
import ninja.shadowfox.shadowfox_botany.api.trees.IridescentSaplingBaseVariant;
15+
import stanhebben.zenscript.annotations.ZenClass;
16+
import stanhebben.zenscript.annotations.ZenMethod;
17+
18+
import java.util.LinkedList;
19+
import java.util.List;
20+
21+
@ZenClass("mods.botanicaladdons.IridescentTree")
22+
public class IridescentTree {
23+
24+
protected static final String name = "Botanical Addons Iridescent Tree";
25+
26+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27+
28+
@ZenMethod
29+
public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves, int metaMin, int metaMax, int metaShift) {
30+
Object soil = InputHelper.toObject(blockSoil);
31+
Object wood = InputHelper.toObject(blockWood);
32+
Object leaves = InputHelper.toObject(blockLeaves);
33+
if (soil == null || !(soil instanceof ItemStack) || !InputHelper.isABlock((ItemStack)soil)) {
34+
LogHelper.logError("Soil must be a block.");
35+
return;
36+
}
37+
else if (wood == null || !(wood instanceof ItemStack) || !InputHelper.isABlock((ItemStack)wood)) {
38+
LogHelper.logError("Wood must be a block.");
39+
return;
40+
}
41+
else if(leaves == null || !(leaves instanceof ItemStack) || !InputHelper.isABlock((ItemStack)leaves)) {
42+
LogHelper.logError("Leaves must be a block.");
43+
return;
44+
}
45+
Block soilBlock = Block.getBlockFromItem(((ItemStack)soil).getItem());
46+
Block woodBlock = Block.getBlockFromItem(((ItemStack)wood).getItem());
47+
Block leavesBlock = Block.getBlockFromItem(((ItemStack)leaves).getItem());
48+
MineTweakerAPI.apply(new Add(new IridescentSaplingBaseVariant(soilBlock, woodBlock, leavesBlock, metaMin, metaMax, metaShift)));
49+
}
50+
51+
@ZenMethod
52+
public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves, int metaMin, int metaMax) {
53+
addVariant(blockSoil, blockWood, blockLeaves, metaMin, metaMax, 0);
54+
}
55+
56+
@ZenMethod
57+
public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves, int meta) {
58+
addVariant(blockSoil, blockWood, blockLeaves, meta, meta, 0);
59+
}
60+
61+
@ZenMethod
62+
public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves) {
63+
addVariant(blockSoil, blockWood, blockLeaves, 0, 15, 0);
64+
}
65+
66+
private static class Add extends BaseListAddition<IIridescentSaplingVariant> {
67+
public Add(IIridescentSaplingVariant recipe) {
68+
super(IridescentTree.name, ShadowFoxAPI.treeVariants);
69+
70+
recipes.add(recipe);
71+
}
72+
73+
@Override
74+
public String getRecipeInfo(IIridescentSaplingVariant recipe) {
75+
return LogHelper.getStackDescription(new ItemStack(recipe.getAcceptableSoils().get(0)));
76+
}
77+
}
78+
79+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
80+
81+
@ZenMethod
82+
public static void removeRecipe(IItemStack blockSoil) {
83+
// Get list of existing recipes, matching with parameter
84+
85+
Object soil = InputHelper.toObject(blockSoil);
86+
if (soil == null || !(soil instanceof ItemStack) || !InputHelper.isABlock((ItemStack)soil)) {
87+
LogHelper.logError("Soil must be a block.");
88+
return;
89+
}
90+
Block soilBlock = Block.getBlockFromItem(((ItemStack)soil).getItem());
91+
92+
List<IIridescentSaplingVariant> recipes = new LinkedList<IIridescentSaplingVariant>();
93+
94+
for (IIridescentSaplingVariant r : ShadowFoxAPI.treeVariants) {
95+
if (r != null && r instanceof IridescentSaplingBaseVariant && r.getAcceptableSoils().get(0) == soilBlock) {
96+
recipes.add(r);
97+
}
98+
}
99+
100+
// Check if we found the recipes and apply the action
101+
if(!recipes.isEmpty()) {
102+
MineTweakerAPI.apply(new Remove(recipes));
103+
} else {
104+
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", IridescentTree.name, soilBlock.toString()));
105+
}
106+
}
107+
108+
private static class Remove extends BaseListRemoval<IIridescentSaplingVariant> {
109+
public Remove(List<IIridescentSaplingVariant> recipes) {
110+
super(IridescentTree.name, ShadowFoxAPI.treeVariants, recipes);
111+
}
112+
113+
@Override
114+
public String getRecipeInfo(IIridescentSaplingVariant recipe) {
115+
return LogHelper.getStackDescription(new ItemStack(recipe.getAcceptableSoils().get(0)));
116+
}
117+
}
118+
}
119+

0 commit comments

Comments
 (0)