Botania Support (#556)

* It turns on and it might work idk

* actually register

might need to be moved to @ZenRegister but I don't really understand
that rn

* move to @ZenRegister

* names

* fix removals being broken entirely and add tests

I think jared is going to hit me with a hammer for not using the late
system in place, but I tried rewriting the IActions to work like that
and uh... Fire everywhere.

* runnable was a better idea

* manually log stuff

* remove printlns from commands

also format because everything is a mess right now between old/new
formats.  Only formats the botania package.

* Add describes

also switches messages to links to the crt log

* minor issue
This commit is contained in:
Brennan Ward 2017-12-13 06:08:18 -05:00 committed by Jared
parent e473d50000
commit fbb7b33866
35 changed files with 1950 additions and 10 deletions

1
.gitignore vendored
View file

@ -54,3 +54,4 @@
/.nb-gradle/private/
/common
*.launch

View file

@ -59,7 +59,7 @@ dependencies {
deobfCompile ("cofh:ThermalExpansion:1.12-5.3.+:deobf"){
exclude group: 'mezz.jei'
}
deobfCompile ("betterwithmods:BetterWithMods:1.12-2.0.15-197:dev"){
compileOnly ("betterwithmods:BetterWithMods:1.12-2.0.15-197:dev"){
exclude group: 'mezz.jei'
}
deobfCompile ("de.ellpeck.actuallyadditions:ActuallyAdditions:1.12.1-r121"){

BIN
libs/Baubles-1.12-1.5.1.jar Normal file

Binary file not shown.

Binary file not shown.

View file

@ -1,16 +1,25 @@
package com.blamejared;
import com.blamejared.compat.tconstruct.TConstruct;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import net.minecraftforge.fml.common.*;
import net.minecraftforge.fml.common.event.*;
import static com.blamejared.reference.Reference.DEPENDENCIES;
import static com.blamejared.reference.Reference.MODID;
import static com.blamejared.reference.Reference.NAME;
import static com.blamejared.reference.Reference.VERSION;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import static com.blamejared.reference.Reference.*;
import com.blamejared.compat.botania.Botania;
import com.blamejared.compat.tconstruct.TConstruct;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
@Mod(modid = MODID, name = NAME, version = VERSION, dependencies = DEPENDENCIES)
public class ModTweaker {
@ -20,7 +29,7 @@ public class ModTweaker {
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) throws IOException {
public void preInit(FMLPreInitializationEvent e) {
}
@Mod.EventHandler
@ -29,7 +38,6 @@ public class ModTweaker {
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent e) {
}
@Mod.EventHandler
@ -48,5 +56,8 @@ public class ModTweaker {
if(Loader.isModLoaded("tconstruct")) {
TConstruct.registerCommands();
}
if(Loader.isModLoaded("botania")) {
Botania.registerCommands();
}
}
}

View file

@ -0,0 +1,34 @@
package com.blamejared.compat.botania;
import com.blamejared.compat.botania.commands.BotaniaBrewLogger;
import com.blamejared.compat.botania.commands.BotaniaLogger;
import com.blamejared.compat.botania.commands.BotaniaOrechidLogger;
import com.blamejared.compat.botania.lexicon.commands.LexiconCategoryLogger;
import com.blamejared.compat.botania.lexicon.commands.LexiconEntryLogger;
import com.blamejared.compat.botania.lexicon.commands.LexiconKnowledgeTypesLogger;
import com.blamejared.compat.botania.lexicon.commands.LexiconPageLogger;
import crafttweaker.mc1120.commands.CTChatCommand;
import net.minecraft.item.ItemStack;
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
public class Botania {
public static boolean isSubtile(ItemStack stack) {
return stack.getItem() instanceof ItemBlockSpecialFlower;
}
public static boolean subtileMatches(ItemStack stack, ItemStack stack2) {
return (ItemBlockSpecialFlower.getType(stack2).equals(ItemBlockSpecialFlower.getType(stack)));
}
public static void registerCommands() {
CTChatCommand.registerCommand(new BotaniaBrewLogger());
CTChatCommand.registerCommand(new BotaniaLogger());
CTChatCommand.registerCommand(new BotaniaOrechidLogger());
CTChatCommand.registerCommand(new LexiconCategoryLogger());
CTChatCommand.registerCommand(new LexiconEntryLogger());
CTChatCommand.registerCommand(new LexiconKnowledgeTypesLogger());
CTChatCommand.registerCommand(new LexiconPageLogger());
}
}

View file

@ -0,0 +1,31 @@
package com.blamejared.compat.botania;
import java.util.List;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.KnowledgeType;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
public class BotaniaHelper {
public static LexiconCategory findCatagory(String name) {
List<LexiconCategory> catagories = BotaniaAPI.getAllCategories();
for (int i = 0; i < catagories.size(); i++) {
if (catagories.get(i).getUnlocalizedName().equalsIgnoreCase(name)) return catagories.get(i);
}
return null;
}
public static LexiconEntry findEntry(String name) {
List<LexiconEntry> entries = BotaniaAPI.getAllEntries();
for (int i = 0; i < entries.size(); i++) {
if (entries.get(i).getUnlocalizedName().equalsIgnoreCase(name)) return entries.get(i);
}
return null;
}
public static KnowledgeType findKnowledgeType(String name) {
if (BotaniaAPI.knowledgeTypes.containsKey(name)) return BotaniaAPI.knowledgeTypes.get(name);
return null;
}
}

View file

@ -0,0 +1,30 @@
package com.blamejared.compat.botania.commands;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.mc1120.commands.CraftTweakerCommand;
import crafttweaker.mc1120.commands.SpecialMessagesChat;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import vazkii.botania.api.BotaniaAPI;
public class BotaniaBrewLogger extends CraftTweakerCommand {
public BotaniaBrewLogger() {
super("botbrews");
}
@Override
public void executeCommand(MinecraftServer server, ICommandSender sender, String[] arguments) {
for (String key : BotaniaAPI.brewMap.keySet()) {
CraftTweakerAPI.logCommand(key);
}
if (sender != null) {
sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List generated;", sender));
}
}
@Override
protected void init() {
}
}

View file

@ -0,0 +1,99 @@
package com.blamejared.compat.botania.commands;
import java.util.Arrays;
import java.util.List;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.helpers.StringHelper;
import com.google.common.collect.ImmutableList;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.mc1120.commands.CraftTweakerCommand;
import crafttweaker.mc1120.commands.SpecialMessagesChat;
import net.minecraft.command.ICommandSender;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.TextComponentString;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipeBrew;
import vazkii.botania.api.recipe.RecipeElvenTrade;
import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.api.recipe.RecipePetals;
import vazkii.botania.api.recipe.RecipePureDaisy;
import vazkii.botania.api.recipe.RecipeRuneAltar;
public class BotaniaLogger extends CraftTweakerCommand {
private static final List<String> ARGS = ImmutableList.of("apothecary", "brews", "trades", "infusions", "daisy", "altar");
public BotaniaLogger() {
super("botania");
}
@SuppressWarnings("deprecation")
@Override
public void executeCommand(MinecraftServer server, ICommandSender sender, String[] arguments) {
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
if (args.contains("apothecary")) {
for (RecipePetals recipe : BotaniaAPI.petalRecipes) {
CraftTweakerAPI.logCommand("Botania Apothecary Recipes");
CraftTweakerAPI.logCommand(String.format("mods.botania.Apothecary.addRecipe(%s, %s);", LogHelper.getStackDescription(recipe.getOutput()), LogHelper.getListDescription(recipe.getInputs()) // Need to resolve "petalXXX" to an item
));
}
}
else if (args.contains("brews")) {
for (RecipeBrew recipe : BotaniaAPI.brewRecipes) {
CraftTweakerAPI.logCommand("Botania Brewing Recipes");
CraftTweakerAPI.logCommand(String.format("mods.botania.Brew.addRecipe(%s, \"%s\");", LogHelper.getListDescription(recipe.getInputs()), recipe.getBrew().getKey()));
}
}
else if (args.contains("trades")) {
for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
CraftTweakerAPI.logCommand("Botania Trading Recipes");
CraftTweakerAPI.logCommand(String.format("mods.botania.ElvenTrade.addRecipe(%s, %s);",
//TODO CHECK THIS
LogHelper.getStackDescription(recipe.getOutputs()), LogHelper.getListDescription(recipe.getInputs())));
}
}
else if (args.contains("infusions")) {
for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) {
CraftTweakerAPI.logCommand("Botania Infusion Recipes");
CraftTweakerAPI.logCommand(String.format("mods.botania.ManaInfusion.add%s(%s, %s, %d);", recipe.isAlchemy() ? "Alchemy" : recipe.isConjuration() ? "Conjuration" : "Infusion", LogHelper.getStackDescription(recipe.getOutput()), LogHelper.getStackDescription(recipe.getInput()), recipe.getManaToConsume()));
}
}
else if (args.contains("daisy")) {
for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) {
CraftTweakerAPI.logCommand("Botania Daisy Recipes");
CraftTweakerAPI.logCommand(String.format("mods.botania.PureDaisy.addRecipe(%s, %s);", LogHelper.getStackDescription(recipe.getInput()),
//TODO CHECK THIS
LogHelper.getStackDescription(new ItemStack(recipe.getOutputState().getBlock(), 1))));
}
}
else if (args.contains("altar")) {
for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) {
CraftTweakerAPI.logCommand("Botania Altar Recipes");
CraftTweakerAPI.logCommand(String.format("mods.botania.RuneAltar.addRecipe(%s, %s, %d);", LogHelper.getStackDescription(recipe.getOutput()), LogHelper.getListDescription(recipe.getInputs()), recipe.getManaUsage()));
}
} else {
if (sender != null) {
sender.sendMessage(new TextComponentString("Invalid arguments for command. Valid arguments: " + StringHelper.join(ARGS, ", ")));
}
return;
}
if (sender != null) {
sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List generated;", sender));
}
}
@Override
protected void init() {
}
}

View file

@ -0,0 +1,30 @@
package com.blamejared.compat.botania.commands;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.mc1120.commands.CraftTweakerCommand;
import crafttweaker.mc1120.commands.SpecialMessagesChat;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import vazkii.botania.api.BotaniaAPI;
public class BotaniaOrechidLogger extends CraftTweakerCommand {
public BotaniaOrechidLogger() {
super("botorechid");
}
@Override
public void executeCommand(MinecraftServer server, ICommandSender sender, String[] arguments) {
for (String str : BotaniaAPI.oreWeights.keySet()) {
CraftTweakerAPI.logCommand(str + ": " + BotaniaAPI.oreWeights.get(str));
}
if (sender != null) {
sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List generated;", sender));
}
}
@Override
protected void init() {
}
}

View file

@ -0,0 +1,110 @@
package com.blamejared.compat.botania.handlers;
import static com.blamejared.mtlib.helpers.InputHelper.toIItemStack;
import static com.blamejared.mtlib.helpers.InputHelper.toObjects;
import static com.blamejared.mtlib.helpers.InputHelper.toStack;
import static com.blamejared.mtlib.helpers.StackHelper.matches;
import java.util.Collections;
import java.util.LinkedList;
import com.blamejared.ModTweaker;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.BaseListAddition;
import com.blamejared.mtlib.utils.BaseListRemoval;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipePetals;
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
@ZenClass("mods.botania.Apothecary")
@ModOnly("botania")
@ZenRegister
public class Apothecary {
protected static final String name = "Botania Petal";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[] input) {
CraftTweakerAPI.apply(new Add(new RecipePetals(toStack(output), toObjects(input))));
}
@ZenMethod
public static void addRecipe(String output, IIngredient[] input) {
addRecipe(toIItemStack(ItemBlockSpecialFlower.ofType(output)), input);
}
private static class Add extends BaseListAddition<RecipePetals> {
public Add(RecipePetals recipe) {
super("Botania Petal", BotaniaAPI.petalRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo(RecipePetals recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IIngredient output) {
ModTweaker.LATE_REMOVALS.add(new Remove(output));
}
@ZenMethod
public static void removeRecipe(String output) {
removeRecipe(toIItemStack(ItemBlockSpecialFlower.ofType(output)));
}
private static class Remove extends BaseListRemoval<RecipePetals> {
final IIngredient output;
public Remove(IIngredient output) {
super(Apothecary.name, BotaniaAPI.petalRecipes, Collections.emptyList());
this.output = output;
}
@Override
public String getRecipeInfo(RecipePetals recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
@Override
public void apply() {
// Get list of existing recipes, matching with parameter
LinkedList<RecipePetals> result = new LinkedList<>();
for (RecipePetals entry : BotaniaAPI.petalRecipes) {
if (entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) {
result.add(entry);
}
}
// Check if we found the recipes and apply the action
if (!result.isEmpty()) {
this.recipes.addAll(result);
super.apply();
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Apothecary.name, output.toString()));
}
CraftTweakerAPI.getLogger().logInfo(super.describe());
}
@Override
public String describe() {
return "Attempting to remove apothecary recipe for " + output.getItems();
}
}
}

View file

@ -0,0 +1,110 @@
package com.blamejared.compat.botania.handlers;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.blamejared.ModTweaker;
import com.blamejared.mtlib.helpers.InputHelper;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.helpers.StringHelper;
import com.blamejared.mtlib.utils.BaseListAddition;
import com.blamejared.mtlib.utils.BaseListRemoval;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IIngredient;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipeBrew;
@ZenClass("mods.botania.Brew")
@ModOnly("botania")
@ZenRegister
public class Brew {
public static final String name = "Botania Brew";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IIngredient[] inputItems, String brewName) {
if (inputItems == null || inputItems.length == 0 || brewName == null || brewName.length() == 0) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if (!BotaniaAPI.brewMap.containsKey(brewName)) {
LogHelper.logError(String.format("Unknown brew name \"%s\" for %s recipe.", brewName, name));
}
RecipeBrew recipe = new RecipeBrew(BotaniaAPI.brewMap.get(brewName), InputHelper.toObjects(inputItems));
CraftTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition<RecipeBrew> {
protected Add(RecipeBrew recipe) {
super(Brew.name, BotaniaAPI.brewRecipes);
recipes.add(recipe);
}
@Override
protected String getRecipeInfo(RecipeBrew recipe) {
return recipe.getBrew().getKey();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(String brewName) {
ModTweaker.LATE_REMOVALS.add(new Remove(brewName));
}
public static class Remove extends BaseListRemoval<RecipeBrew> {
final String brewName;
protected Remove(String brewName) {
super(Brew.name, BotaniaAPI.brewRecipes, Collections.emptyList());
this.brewName = brewName;
}
@Override
protected String getRecipeInfo(RecipeBrew recipe) {
return recipe.getBrew().getKey();
}
@Override
public void apply() {
List<RecipeBrew> recipes = new LinkedList<RecipeBrew>();
Matcher matcher = Pattern.compile(StringHelper.wildcardToRegex(brewName)).matcher("");
for (RecipeBrew recipe : BotaniaAPI.brewRecipes) {
matcher.reset(recipe.getBrew().getKey());
if (matcher.matches()) {
recipes.add(recipe);
}
}
if (!recipes.isEmpty()) {
this.recipes.addAll(recipes);
super.apply();
} else {
LogHelper.logWarning(String.format("No %s recipe found for %s. Command ignored!", name, brewName));
}
CraftTweakerAPI.getLogger().logInfo(super.describe());
}
@Override
public String describe() {
return "Attempting to remove brewing recipe for " + brewName;
}
}
}

View file

@ -0,0 +1,112 @@
package com.blamejared.compat.botania.handlers;
import static com.blamejared.mtlib.helpers.InputHelper.toObjects;
import static com.blamejared.mtlib.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import com.blamejared.ModTweaker;
import com.blamejared.mtlib.helpers.InputHelper;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.BaseListAddition;
import com.blamejared.mtlib.utils.BaseListRemoval;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import crafttweaker.mc1120.item.MCItemStack;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipeElvenTrade;
@ZenClass("mods.botania.ElvenTrade")
@ModOnly("botania")
@ZenRegister
public class ElvenTrade {
protected static final String name = "Botania Eleven Trade";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack[] outputs, IIngredient[] input) {
CraftTweakerAPI.apply(new Add(new RecipeElvenTrade(InputHelper.toStacks(outputs), toObjects(input))));
}
private static class Add extends BaseListAddition<RecipeElvenTrade> {
public Add(RecipeElvenTrade recipe) {
super(ElvenTrade.name, BotaniaAPI.elvenTradeRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo(RecipeElvenTrade recipe) {
return LogHelper.getStackDescription(recipe.getOutputs());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IIngredient output) {
ModTweaker.LATE_REMOVALS.add(new Remove(output));
}
public static IItemStack[] toStacks(ItemStack[] iIngredient) {
ArrayList<IItemStack> stacks = new ArrayList<>();
for (ItemStack stack : iIngredient) {
stacks.add(new MCItemStack(stack));
}
return stacks.toArray(new IItemStack[stacks.size()]);
}
private static class Remove extends BaseListRemoval<RecipeElvenTrade> {
final IIngredient output;
public Remove(IIngredient output) {
super(ElvenTrade.name, BotaniaAPI.elvenTradeRecipes, Collections.emptyList());
this.output = output;
}
@Override
public String getRecipeInfo(RecipeElvenTrade recipe) {
return LogHelper.getStackDescription(recipe.getOutputs());
}
@Override
public void apply() {
// Get list of existing recipes, matching with parameter
LinkedList<RecipeElvenTrade> recipes = new LinkedList<RecipeElvenTrade>();
for (RecipeElvenTrade entry : BotaniaAPI.elvenTradeRecipes) {
if (entry != null && entry.getOutputs() != null && matches(output, toStacks(entry.getOutputs().toArray(new ItemStack[entry.getOutputs().size()])))) {
recipes.add(entry);
}
}
// Check if we found the recipes and apply the action
if (!recipes.isEmpty()) {
this.recipes.addAll(recipes);
super.apply();
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ElvenTrade.name, output.toString()));
}
CraftTweakerAPI.getLogger().logInfo(super.describe());
}
@Override
public String describe() {
return "Attempting to remove Elven Trade recipe for " + output.getItems();
}
}
}

View file

@ -0,0 +1,378 @@
package com.blamejared.compat.botania.handlers;
import static com.blamejared.mtlib.helpers.InputHelper.toObject;
import static com.blamejared.mtlib.helpers.InputHelper.toObjects;
import static com.blamejared.mtlib.helpers.InputHelper.toStack;
import static com.blamejared.mtlib.helpers.InputHelper.toStacks;
import java.util.ArrayList;
import java.util.List;
import com.blamejared.ModTweaker;
import com.blamejared.compat.botania.BotaniaHelper;
import com.blamejared.compat.botania.lexicon.AddCategory;
import com.blamejared.compat.botania.lexicon.AddEntry;
import com.blamejared.compat.botania.lexicon.AddPage;
import com.blamejared.compat.botania.lexicon.AddRecipeMapping;
import com.blamejared.compat.botania.lexicon.RemoveCategory;
import com.blamejared.compat.botania.lexicon.RemoveEntry;
import com.blamejared.compat.botania.lexicon.RemovePage;
import com.blamejared.compat.botania.lexicon.RemoveRecipeMapping;
import com.blamejared.compat.botania.lexicon.SetCategoryIcon;
import com.blamejared.compat.botania.lexicon.SetCategoryPriority;
import com.blamejared.compat.botania.lexicon.SetEntryKnowledgeType;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import net.minecraft.entity.EntityList;
import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.api.lexicon.LexiconRecipeMappings;
import vazkii.botania.api.recipe.RecipeBrew;
import vazkii.botania.api.recipe.RecipeElvenTrade;
import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.api.recipe.RecipePetals;
import vazkii.botania.api.recipe.RecipeRuneAltar;
import vazkii.botania.common.lexicon.page.PageBrew;
import vazkii.botania.common.lexicon.page.PageCraftingRecipe;
import vazkii.botania.common.lexicon.page.PageElvenRecipe;
import vazkii.botania.common.lexicon.page.PageEntity;
import vazkii.botania.common.lexicon.page.PageImage;
import vazkii.botania.common.lexicon.page.PageLoreText;
import vazkii.botania.common.lexicon.page.PageManaInfusionRecipe;
import vazkii.botania.common.lexicon.page.PagePetalRecipe;
import vazkii.botania.common.lexicon.page.PageRuneRecipe;
import vazkii.botania.common.lexicon.page.PageText;
@ZenClass("mods.botania.Lexicon")
@ModOnly("botania")
@ZenRegister
public class Lexicon {
@ZenMethod
public static void addBrewPage(String name, String entry, int page_number, String brew, IIngredient[] recipe, String bottomText) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
if (BotaniaAPI.getBrewFromKey(brew) == null) {
CraftTweakerAPI.getLogger().logError("Cannot find brew " + brew);
return;
}
RecipeBrew page_recipe = new RecipeBrew(BotaniaAPI.getBrewFromKey(brew), toObjects(recipe));
LexiconPage page = new PageBrew(page_recipe, name, bottomText);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addCraftingPage(String name, String entry, int page_number, String... recipeNames) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
List<ResourceLocation> recipes = new ArrayList<>();
for (String s : recipeNames) {
recipes.add(new ResourceLocation(s));
}
LexiconPage page = new PageCraftingRecipe(name, recipes);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addElvenPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][] inputs) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
if (outputs.length != inputs.length) {
CraftTweakerAPI.getLogger().logError("Length of input and output must match");
return;
}
List<RecipeElvenTrade> recipes = new ArrayList<RecipeElvenTrade>();
for (int i = 0; i < outputs.length; i++) {
//TODO test
recipes.add(new RecipeElvenTrade(toStacks(outputs), toObjects(inputs[i])));
}
LexiconPage page = new PageElvenRecipe(name, recipes);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addEntityPage(String name, String entry, int page_number, String entity, int size) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
if (!EntityList.isRegistered(new ResourceLocation(entity))) {
CraftTweakerAPI.getLogger().logError("No such entity " + entity);
return;
}
LexiconPage page = new PageEntity(entity, entity, size);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addImagePage(String name, String entry, int page_number, String resource) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
LexiconPage page = new PageImage(name, resource);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addLorePage(String name, String entry, int page_number) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
LexiconPage page = new PageLoreText(name);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addInfusionPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[] inputs, int[] mana) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
if (outputs.length != inputs.length || outputs.length != mana.length) {
CraftTweakerAPI.getLogger().logError("Length of input and output must match");
return;
}
List<RecipeManaInfusion> recipes = new ArrayList<RecipeManaInfusion>();
for (int i = 0; i < outputs.length; i++) {
recipes.add(new RecipeManaInfusion(toStack(outputs[i]), toObject(inputs[i]), mana[i]));
}
LexiconPage page = new PageManaInfusionRecipe(name, recipes);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addAlchemyPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[] inputs, int[] mana) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
if (outputs.length != inputs.length || outputs.length != mana.length) {
CraftTweakerAPI.getLogger().logError("Length of input and output must match");
return;
}
List<RecipeManaInfusion> recipes = new ArrayList<RecipeManaInfusion>();
for (int i = 0; i < outputs.length; i++) {
RecipeManaInfusion current_recipe = new RecipeManaInfusion(toStack(outputs[i]), toObject(inputs[i]), mana[i]);
current_recipe.setCatalyst(RecipeManaInfusion.alchemyState);
recipes.add(current_recipe);
}
LexiconPage page = new PageManaInfusionRecipe(name, recipes);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addConjurationPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[] inputs, int[] mana) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
if (outputs.length != inputs.length || outputs.length != mana.length) {
CraftTweakerAPI.getLogger().logError("Length of input and output must match");
return;
}
List<RecipeManaInfusion> recipes = new ArrayList<RecipeManaInfusion>();
for (int i = 0; i < outputs.length; i++) {
RecipeManaInfusion current_recipe = new RecipeManaInfusion(toStack(outputs[i]), toObject(inputs[i]), mana[i]);
current_recipe.setCatalyst(RecipeManaInfusion.conjurationState);
recipes.add(current_recipe);
}
LexiconPage page = new PageManaInfusionRecipe(name, recipes);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addPetalPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][] inputs) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
if (outputs.length != inputs.length) {
CraftTweakerAPI.getLogger().logError("Length of input and output must match");
return;
}
List<RecipePetals> recipes = new ArrayList<RecipePetals>();
for (int i = 0; i < outputs.length; i++) {
recipes.add(new RecipePetals(toStack(outputs[i]), toObjects(inputs[i])));
}
LexiconPage page = new PagePetalRecipe<>(name, recipes);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addRunePage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][] inputs, int[] mana) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
if (outputs.length != inputs.length || outputs.length != mana.length) {
CraftTweakerAPI.getLogger().logError("Length of input and output must match");
return;
}
List<RecipeRuneAltar> recipes = new ArrayList<RecipeRuneAltar>();
for (int i = 0; i < outputs.length; i++) {
recipes.add(new RecipeRuneAltar(toStack(outputs[i]), mana[i], toObjects(inputs[i])));
}
LexiconPage page = new PageRuneRecipe(name, recipes);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void addTextPage(String name, String entry, int page_number) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry);
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number > lexiconEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
LexiconPage page = new PageText(name);
CraftTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number));
}
@ZenMethod
public static void removePage(String entry, int page_number) {
ModTweaker.LATE_REMOVALS.add(new RemovePage(entry, page_number));
}
@ZenMethod
public static void addEntry(String entry, String catagory, IItemStack stack) {
LexiconCategory lexiconCategory = BotaniaHelper.findCatagory(catagory);
if (lexiconCategory == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon category " + catagory);
return;
}
LexiconEntry lexiconEntry = new LexiconEntry(entry, lexiconCategory);
lexiconEntry.setIcon(toStack(stack));
CraftTweakerAPI.apply(new AddEntry(lexiconEntry));
}
@ZenMethod
public static void removeEntry(String entry) {
ModTweaker.LATE_REMOVALS.add(new RemoveEntry(entry));
}
@ZenMethod
public static void setEntryKnowledgeType(String entry, String knowledgeType) {
ModTweaker.LATE_REMOVALS.add(new SetEntryKnowledgeType(entry, knowledgeType));
}
@ZenMethod
public static void addCategory(String name) {
LexiconCategory lexiconCategory = new LexiconCategory(name);
CraftTweakerAPI.apply(new AddCategory(lexiconCategory));
}
@ZenMethod
public static void removeCategory(String name) {
ModTweaker.LATE_REMOVALS.add(new RemoveCategory(name));
}
@ZenMethod
public static void setCategoryPriority(String name, int priority) {
ModTweaker.LATE_REMOVALS.add(new SetCategoryPriority(name, priority));
}
@ZenMethod
public static void setCategoryIcon(String name, String icon) {
ModTweaker.LATE_REMOVALS.add(new SetCategoryIcon(name, icon));
}
@ZenMethod
public static void addRecipeMapping(IItemStack stack, String Entry, int page) {
LexiconEntry lexiconEntry = BotaniaHelper.findEntry(Entry);
if (LexiconRecipeMappings.getDataForStack(toStack(stack)) != null) {
CraftTweakerAPI.getLogger().logError("There is already a recipe mapping for " + stack);
return;
}
if (lexiconEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + Entry);
return;
}
if (lexiconEntry.pages.size() < page) {
CraftTweakerAPI.getLogger().logError("Not enough pages in " + Entry);
return;
}
CraftTweakerAPI.apply(new AddRecipeMapping(toStack(stack), lexiconEntry, page));
}
@ZenMethod
public static void removeRecipeMapping(IItemStack stack) {
ModTweaker.LATE_REMOVALS.add(new RemoveRecipeMapping(stack));
}
}

View file

@ -0,0 +1,112 @@
package com.blamejared.compat.botania.handlers;
import static com.blamejared.mtlib.helpers.InputHelper.toIItemStack;
import static com.blamejared.mtlib.helpers.InputHelper.toObject;
import static com.blamejared.mtlib.helpers.InputHelper.toStack;
import static com.blamejared.mtlib.helpers.StackHelper.matches;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import com.blamejared.ModTweaker;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.BaseListAddition;
import com.blamejared.mtlib.utils.BaseListRemoval;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipeManaInfusion;
@ZenClass("mods.botania.ManaInfusion")
@ModOnly("botania")
@ZenRegister
public class ManaInfusion {
protected static final String name = "Botania Mana Infusion";
@ZenMethod
public static void addInfusion(IItemStack output, IIngredient input, int mana) {
CraftTweakerAPI.apply(new Add(new RecipeManaInfusion(toStack(output), toObject(input), mana)));
}
@ZenMethod
public static void addAlchemy(IItemStack output, IIngredient input, int mana) {
RecipeManaInfusion recipe = new RecipeManaInfusion(toStack(output), toObject(input), mana);
recipe.setCatalyst(RecipeManaInfusion.alchemyState);
CraftTweakerAPI.apply(new Add(recipe));
}
@ZenMethod
public static void addConjuration(IItemStack output, IIngredient input, int mana) {
RecipeManaInfusion recipe = new RecipeManaInfusion(toStack(output), toObject(input), mana);
recipe.setCatalyst(RecipeManaInfusion.conjurationState);
CraftTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition<RecipeManaInfusion> {
public Add(RecipeManaInfusion recipe) {
super(ManaInfusion.name, BotaniaAPI.manaInfusionRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo(RecipeManaInfusion recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IIngredient output) {
ModTweaker.LATE_REMOVALS.add(new Remove(output));
}
private static class Remove extends BaseListRemoval<RecipeManaInfusion> {
final IIngredient output;
public Remove(IIngredient output) {
super(ManaInfusion.name, BotaniaAPI.manaInfusionRecipes, Collections.emptyList());
this.output = output;
}
@Override
public String getRecipeInfo(RecipeManaInfusion recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
@Override
public void apply() {
// Get list of existing recipes, matching with parameter
List<RecipeManaInfusion> recipes = new LinkedList<RecipeManaInfusion>();
for (RecipeManaInfusion r : BotaniaAPI.manaInfusionRecipes) {
if (r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) {
recipes.add(r);
}
}
// Check if we found the recipes and apply the action
if (!recipes.isEmpty()) {
this.recipes.addAll(recipes);
super.apply();
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ManaInfusion.name, output.toString()));
}
CraftTweakerAPI.getLogger().logInfo(super.describe());
}
@Override
public String describe() {
return "Attempting to remove mana infusion recipe for " + output.getItems();
}
}
}

View file

@ -0,0 +1,76 @@
package com.blamejared.compat.botania.handlers;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.oredict.IOreDictEntry;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
@ZenClass("mods.botania.Orechid")
@ModOnly("botania")
@ZenRegister
public class Orechid {
@ZenMethod
public static void addOre(IOreDictEntry oreDict, int weight) {
CraftTweakerAPI.apply(new Add(oreDict.getName(), weight));
}
@ZenMethod
public static void addOre(String oreDict, int weight) {
CraftTweakerAPI.apply(new Add(oreDict, weight));
}
private static class Add implements IAction {
String oreDict;
int weight;
public Add(String ore, int prop) {
oreDict = ore;
weight = prop;
}
@Override
public void apply() {
BotaniaAPI.addOreWeight(oreDict, weight);
}
@Override
public String describe() {
return "Adding Orechid Ore Weight: " + oreDict + ":" + weight;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeOre(IOreDictEntry oreDict) {
CraftTweakerAPI.apply(new Remove(oreDict.getName()));
}
@ZenMethod
public static void removeOre(String oreDict) {
CraftTweakerAPI.apply(new Remove(oreDict));
}
private static class Remove implements IAction {
String oreDict;
public Remove(String ore) {
oreDict = ore;
}
@Override
public void apply() {
BotaniaAPI.oreWeights.remove(oreDict);
}
@Override
public String describe() {
return "Removing Orechid Ore: " + oreDict;
}
}
}

View file

@ -0,0 +1,117 @@
package com.blamejared.compat.botania.handlers;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import com.blamejared.ModTweaker;
import com.blamejared.mtlib.helpers.InputHelper;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.helpers.StackHelper;
import com.blamejared.mtlib.utils.BaseListAddition;
import com.blamejared.mtlib.utils.BaseListRemoval;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipePureDaisy;
@ZenClass("mods.botania.PureDaisy")
@ModOnly("botania")
@ZenRegister
public class PureDaisy {
public static final String name = "Botania PureDaisy";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IIngredient blockInput, IItemStack blockOutput, @Optional int time) {
if (blockInput == null || blockOutput == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
Object input = InputHelper.toObject(blockInput);
if (input == null || (input instanceof ItemStack && !InputHelper.isABlock((ItemStack) input))) {
LogHelper.logError(String.format("Input must be a block or an oredict entry."));
return;
}
if (input instanceof ItemStack) input = Block.getBlockFromItem(((ItemStack) input).getItem());
ItemStack output = InputHelper.toStack(blockOutput);
RecipePureDaisy recipe = new RecipePureDaisy(input, Block.getBlockFromItem(output.getItem()).getDefaultState(), time);
CraftTweakerAPI.apply(new Add(recipe));
}
private static class Add extends BaseListAddition<RecipePureDaisy> {
public Add(RecipePureDaisy recipe) {
super(PureDaisy.name, BotaniaAPI.pureDaisyRecipes);
recipes.add(recipe);
}
@Override
protected String getRecipeInfo(RecipePureDaisy recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.getOutputState().getBlock(), 1));
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IIngredient output) {
ModTweaker.LATE_REMOVALS.add(new Remove(output));
}
private static class Remove extends BaseListRemoval<RecipePureDaisy> {
final IIngredient output;
public Remove(IIngredient output) {
super(PureDaisy.name, BotaniaAPI.pureDaisyRecipes, Collections.emptyList());
this.output = output;
}
@Override
protected String getRecipeInfo(RecipePureDaisy recipe) {
return LogHelper.getStackDescription(new ItemStack(recipe.getOutputState().getBlock(), 1));
}
@Override
public void apply() {
List<RecipePureDaisy> recipes = new LinkedList<>();
for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) {
IItemStack out = InputHelper.toIItemStack(new ItemStack(recipe.getOutputState().getBlock(), 1));
if (StackHelper.matches(output, out)) {
recipes.add(recipe);
}
}
if (!recipes.isEmpty()) {
this.recipes.addAll(recipes);
super.apply();
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", PureDaisy.name, output.toString()));
}
CraftTweakerAPI.getLogger().logInfo(super.describe());
}
@Override
public String describe() {
return "Attempting to remove Pure Daisy recipe for " + output.getItems();
}
}
}

View file

@ -0,0 +1,101 @@
package com.blamejared.compat.botania.handlers;
import static com.blamejared.mtlib.helpers.InputHelper.toIItemStack;
import static com.blamejared.mtlib.helpers.InputHelper.toObjects;
import static com.blamejared.mtlib.helpers.InputHelper.toStack;
import static com.blamejared.mtlib.helpers.StackHelper.matches;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import com.blamejared.ModTweaker;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.BaseListAddition;
import com.blamejared.mtlib.utils.BaseListRemoval;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipeRuneAltar;
@ZenClass("mods.botania.RuneAltar")
@ModOnly("botania")
@ZenRegister
public class RuneAltar {
protected static final String name = "Botania Rune Altar";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addRecipe(IItemStack output, IIngredient[] input, int mana) {
CraftTweakerAPI.apply(new Add(new RecipeRuneAltar(toStack(output), mana, toObjects(input))));
}
private static class Add extends BaseListAddition<RecipeRuneAltar> {
public Add(RecipeRuneAltar recipe) {
super(RuneAltar.name, BotaniaAPI.runeAltarRecipes);
recipes.add(recipe);
}
@Override
public String getRecipeInfo(RecipeRuneAltar recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void removeRecipe(IIngredient output) {
ModTweaker.LATE_REMOVALS.add(new Remove(output));
}
private static class Remove extends BaseListRemoval<RecipeRuneAltar> {
final IIngredient output;
public Remove(IIngredient output) {
super(RuneAltar.name, BotaniaAPI.runeAltarRecipes, Collections.emptyList());
this.output = output;
}
@Override
public String getRecipeInfo(RecipeRuneAltar recipe) {
return LogHelper.getStackDescription(recipe.getOutput());
}
@Override
public void apply() {
// Get list of existing recipes, matching with parameter
List<RecipeRuneAltar> recipes = new LinkedList<RecipeRuneAltar>();
for (RecipeRuneAltar r : BotaniaAPI.runeAltarRecipes) {
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()) {
this.recipes.addAll(recipes);
super.apply();
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", RuneAltar.name, output.toString()));
}
CraftTweakerAPI.getLogger().logInfo(super.describe());
}
@Override
public String describe() {
return "Attempting to remove Rune Altar recipe for " + output.getItems();
}
}
}

View file

@ -0,0 +1,25 @@
package com.blamejared.compat.botania.lexicon;
import crafttweaker.IAction;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
public class AddCategory implements IAction {
LexiconCategory category;
public AddCategory(LexiconCategory category) {
this.category = category;
}
@Override
public void apply() {
BotaniaAPI.addCategory(category);
}
@Override
public String describe() {
return "Adding Lexicon Category: " + category.getUnlocalizedName();
}
}

View file

@ -0,0 +1,25 @@
package com.blamejared.compat.botania.lexicon;
import crafttweaker.IAction;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconEntry;
public class AddEntry implements IAction {
LexiconEntry Entry;
public AddEntry(LexiconEntry Entry) {
this.Entry = Entry;
}
@Override
public void apply() {
BotaniaAPI.addEntry(Entry, Entry.category);
}
@Override
public String describe() {
return "Adding Lexicon Entry: " + Entry.getUnlocalizedName();
}
}

View file

@ -0,0 +1,31 @@
package com.blamejared.compat.botania.lexicon;
import crafttweaker.IAction;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconPage;
public class AddPage implements IAction {
String Name;
int page_number;
LexiconEntry Entry;
LexiconPage page;
public AddPage(String Name, LexiconEntry Entry, LexiconPage page, int page_number) {
this.Name = Name;
this.Entry = Entry;
this.page = page;
this.page_number = page_number;
}
@Override
public void apply() {
Entry.pages.add(page_number, page);
}
@Override
public String describe() {
return "Adding Lexicon Page: " + Name;
}
}

View file

@ -0,0 +1,30 @@
package com.blamejared.compat.botania.lexicon;
import crafttweaker.IAction;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconRecipeMappings;
public class AddRecipeMapping implements IAction {
ItemStack stack;
LexiconEntry entry;
int page;
public AddRecipeMapping(ItemStack stack, LexiconEntry entry, int page) {
this.stack = stack;
this.entry = entry;
this.page = page;
}
@Override
public void apply() {
LexiconRecipeMappings.map(stack, entry, page);
}
@Override
public String describe() {
return "Adding Lexicon Recipe Lookup: " + stack.getUnlocalizedName();
}
}

View file

@ -0,0 +1,35 @@
package com.blamejared.compat.botania.lexicon;
import com.blamejared.compat.botania.BotaniaHelper;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
public class RemoveCategory implements IAction {
final String name;
LexiconCategory category;
public RemoveCategory(String name) {
this.name = name;
}
@Override
public void apply() {
category = BotaniaHelper.findCatagory(name);
if (category == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon category " + name);
return;
}
BotaniaAPI.getAllCategories().remove(category);
CraftTweakerAPI.getLogger().logInfo("Removing Lexicon Category: " + category.getUnlocalizedName());
}
@Override
public String describe() {
return "Attempting to remove Lexicon Category " + name;
}
}

View file

@ -0,0 +1,36 @@
package com.blamejared.compat.botania.lexicon;
import com.blamejared.compat.botania.BotaniaHelper;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconEntry;
public class RemoveEntry implements IAction {
LexiconEntry lexEntry;
final String entry;
public RemoveEntry(String entry) {
this.entry = entry;
}
@Override
public void apply() {
lexEntry = BotaniaHelper.findEntry(entry);
if (lexEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
lexEntry.category.entries.remove(lexEntry);
BotaniaAPI.getAllEntries().remove(lexEntry);
CraftTweakerAPI.getLogger().logInfo("Removing Lexicon Entry: " + lexEntry.getUnlocalizedName());
}
@Override
public String describe() {
return "Attempting to remove Lexicon Entry " + entry;
}
}

View file

@ -0,0 +1,44 @@
package com.blamejared.compat.botania.lexicon;
import com.blamejared.compat.botania.BotaniaHelper;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconPage;
public class RemovePage implements IAction {
int page_number;
LexiconEntry lexEntry;
LexiconPage page;
final String entry;
public RemovePage(String entry, int page_number) {
this.entry = entry;
this.page_number = page_number;
}
@Override
public void apply() {
this.lexEntry = BotaniaHelper.findEntry(entry);
if (lexEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (page_number >= lexEntry.pages.size()) {
CraftTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry);
return;
}
this.page = lexEntry.pages.get(page_number);
lexEntry.pages.remove(page);
CraftTweakerAPI.getLogger().logInfo("Removing Lexicon Page: " + lexEntry.pages.get(page_number).getUnlocalizedName());
}
@Override
public String describe() {
return "Attempting to remove Lexicon Page " + page_number + " from Entry " + entry ;
}
}

View file

@ -0,0 +1,42 @@
package com.blamejared.compat.botania.lexicon;
import static com.blamejared.mtlib.helpers.InputHelper.toStack;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import crafttweaker.api.item.IItemStack;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconRecipeMappings;
import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData;
public class RemoveRecipeMapping implements IAction {
ItemStack stack;
IItemStack iStack;
LexiconEntry entry;
int page;
public RemoveRecipeMapping(IItemStack stack) {
this.iStack = stack;
}
@Override
public void apply() {
if (LexiconRecipeMappings.getDataForStack(stack = toStack(iStack)) == null) {
CraftTweakerAPI.getLogger().logError("There isn't a recipe mapping for " + iStack);
return;
}
EntryData data = LexiconRecipeMappings.getDataForStack(stack);
this.entry = data.entry;
this.page = data.page;
LexiconRecipeMappings.remove(stack);
CraftTweakerAPI.getLogger().logInfo("Removing Lexicon Recipe Lookup: " + stack.getUnlocalizedName());
}
@Override
public String describe() {
return "Attempting to remove recipe mapping for " + toStack(iStack);
}
}

View file

@ -0,0 +1,39 @@
package com.blamejared.compat.botania.lexicon;
import com.blamejared.compat.botania.BotaniaHelper;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import net.minecraft.util.ResourceLocation;
import vazkii.botania.api.lexicon.LexiconCategory;
public class SetCategoryIcon implements IAction {
LexiconCategory category;
ResourceLocation oldIcon;
ResourceLocation newIcon;
final String name;
public SetCategoryIcon(String name, String icon) {
this.name = name;
this.newIcon = new ResourceLocation(icon);
}
@Override
public void apply() {
category = BotaniaHelper.findCatagory(name);
if (category == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon category " + name);
return;
}
oldIcon = category.getIcon();
category.setIcon(newIcon);
CraftTweakerAPI.getLogger().logInfo("Setting Lexicon Category icon: " + category.getUnlocalizedName());
}
@Override
public String describe() {
return "Attempting to set the icon for Lexicon Category " + name + " to " + newIcon;
}
}

View file

@ -0,0 +1,38 @@
package com.blamejared.compat.botania.lexicon;
import com.blamejared.compat.botania.BotaniaHelper;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import vazkii.botania.api.lexicon.LexiconCategory;
public class SetCategoryPriority implements IAction {
LexiconCategory category;
int oldPriority;
int newPriority;
final String name;
public SetCategoryPriority(String name, int priority) {
this.name = name;
this.newPriority = priority;
}
@Override
public void apply() {
category = BotaniaHelper.findCatagory(name);
if (category == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon category " + name);
return;
}
oldPriority = category.getSortingPriority();
category.setPriority(newPriority);
CraftTweakerAPI.getLogger().logInfo("Setting Lexicon Category priority: " + category.getUnlocalizedName());
}
@Override
public String describe() {
return "Attempting to set the priority for Lexicon Category " + name + " to " + newPriority;
}
}

View file

@ -0,0 +1,44 @@
package com.blamejared.compat.botania.lexicon;
import com.blamejared.compat.botania.BotaniaHelper;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import vazkii.botania.api.lexicon.KnowledgeType;
import vazkii.botania.api.lexicon.LexiconEntry;
public class SetEntryKnowledgeType implements IAction {
LexiconEntry lexEntry;
KnowledgeType newType;
KnowledgeType oldType;
final String entry;
final String knowledgeType;
public SetEntryKnowledgeType(String entry, String knowledgeType) {
this.entry = entry;
this.knowledgeType = knowledgeType;
}
@Override
public void apply() {
lexEntry = BotaniaHelper.findEntry(entry);
newType = BotaniaHelper.findKnowledgeType(knowledgeType);
if (lexEntry == null) {
CraftTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry);
return;
}
if (newType == null) {
CraftTweakerAPI.getLogger().logError("Cannot find knowledge type " + knowledgeType);
return;
}
oldType = lexEntry.getKnowledgeType();
lexEntry.setKnowledgeType(newType);
CraftTweakerAPI.getLogger().logInfo("Setting Knowledge type for: " + lexEntry.getUnlocalizedName());
}
@Override
public String describe() {
return "Attempting to set the knowledge type for Lexicon Entry " + entry + " to " + knowledgeType;
}
}

View file

@ -0,0 +1,32 @@
package com.blamejared.compat.botania.lexicon.commands;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.mc1120.commands.CraftTweakerCommand;
import crafttweaker.mc1120.commands.SpecialMessagesChat;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
public class LexiconCategoryLogger extends CraftTweakerCommand {
public LexiconCategoryLogger() {
super("botlexcats");
}
@Override
public void executeCommand(MinecraftServer server, ICommandSender sender, String[] arguments) {
CraftTweakerAPI.logCommand("Botania Lexicon Categories");
for (LexiconCategory category : BotaniaAPI.getAllCategories()) {
CraftTweakerAPI.logCommand(category.getUnlocalizedName());
}
if (sender != null) {
sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List generated;", sender));
}
}
@Override
protected void init() {
}
}

View file

@ -0,0 +1,45 @@
package com.blamejared.compat.botania.lexicon.commands;
import com.blamejared.compat.botania.BotaniaHelper;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.mc1120.commands.CraftTweakerCommand;
import crafttweaker.mc1120.commands.SpecialMessagesChat;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
public class LexiconEntryLogger extends CraftTweakerCommand {
public LexiconEntryLogger() {
super("botlexentries");
}
@Override
public void executeCommand(MinecraftServer server, ICommandSender sender, String[] arguments) {
LexiconCategory category = null;
if (arguments.length > 0) {
category = BotaniaHelper.findCatagory(arguments[0]);
if (category == null) {
CraftTweakerAPI.getLogger().logError("Category not found (" + arguments[0] + ")");
return;
}
}
CraftTweakerAPI.logCommand("Botania Lexicon Entries");
for (LexiconEntry entry : BotaniaAPI.getAllEntries()) {
if (category == null || entry.category == category) {
CraftTweakerAPI.logCommand(entry.getUnlocalizedName());
}
}
if (sender != null) {
sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List generated;", sender));
}
}
@Override
protected void init() {
}
}

View file

@ -0,0 +1,31 @@
package com.blamejared.compat.botania.lexicon.commands;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.mc1120.commands.CraftTweakerCommand;
import crafttweaker.mc1120.commands.SpecialMessagesChat;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import vazkii.botania.api.BotaniaAPI;
public class LexiconKnowledgeTypesLogger extends CraftTweakerCommand {
public LexiconKnowledgeTypesLogger() {
super("botlextypes");
}
@Override
public void executeCommand(MinecraftServer server, ICommandSender sender, String[] arguments) {
CraftTweakerAPI.logCommand("Botania Lexicon Knowledge Types");
for (String key : BotaniaAPI.knowledgeTypes.keySet()) {
CraftTweakerAPI.logCommand(key);
}
if (sender != null) {
sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List generated;", sender));
}
}
@Override
protected void init() {
}
}

View file

@ -0,0 +1,51 @@
package com.blamejared.compat.botania.lexicon.commands;
import java.util.ArrayList;
import java.util.List;
import com.blamejared.compat.botania.BotaniaHelper;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.mc1120.commands.CraftTweakerCommand;
import crafttweaker.mc1120.commands.SpecialMessagesChat;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconPage;
public class LexiconPageLogger extends CraftTweakerCommand {
public LexiconPageLogger() {
super("botlexpages");
}
@Override
public void executeCommand(MinecraftServer server, ICommandSender sender, String[] arguments) {
LexiconEntry entry = null;
if (arguments.length > 0) {
entry = BotaniaHelper.findEntry(arguments[0]);
if (entry == null) {
CraftTweakerAPI.getLogger().logError("Entry not found (" + arguments[0] + ")");
return;
}
}
List<LexiconPage> pages = new ArrayList<>();
if (entry != null) pages.addAll(entry.pages);
else for (LexiconEntry current_Entry : BotaniaAPI.getAllEntries())
pages.addAll(current_Entry.pages);
CraftTweakerAPI.logCommand("Botania Lexicon Pages");
for (LexiconPage page : pages) {
CraftTweakerAPI.logCommand(page.getUnlocalizedName() + " (" + page.getClass() + ")");
}
if (sender != null) {
sender.sendMessage(SpecialMessagesChat.getLinkToCraftTweakerLog("List generated;", sender));
}
}
@Override
protected void init() {
}
}

1
test_scripts/README.md Normal file
View file

@ -0,0 +1 @@
This folder is to hold ModTweaker test scrips for ease of making sure everything works properly.

39
test_scripts/botania.zs Normal file
View file

@ -0,0 +1,39 @@
mods.botania.Apothecary.addRecipe(<minecraft:apple>, [<minecraft:stone>, <minecraft:nether_star>]);
mods.botania.Apothecary.addRecipe("hydroangeas", [<minecraft:apple>, <minecraft:cobblestone>]);
mods.botania.Apothecary.removeRecipe(<botania:specialflower>.withTag({type: "fallenKanade"}));
mods.botania.Apothecary.removeRecipe("thermalily");
mods.botania.Brew.addRecipe([<minecraft:apple>, <minecraft:nether_star>], "healing");
mods.botania.Brew.removeRecipe("resistance");
mods.botania.ElvenTrade.addRecipe([<minecraft:apple>], [<minecraft:nether_star>]);
mods.botania.ElvenTrade.removeRecipe(<botania:quartz:5>);
mods.botania.ManaInfusion.addInfusion(<minecraft:apple>, <minecraft:nether_star>, 140);
mods.botania.ManaInfusion.addAlchemy(<minecraft:stone>, <minecraft:bookshelf>, 40);
mods.botania.ManaInfusion.addConjuration(<minecraft:bookshelf>, <minecraft:book>, 500);
mods.botania.ManaInfusion.removeRecipe(<minecraft:ice>);
mods.botania.Orechid.addOre(<ore:blockIron>, 40000);
mods.botania.Orechid.addOre("blockQuartz", 99999);
mods.botania.Orechid.removeOre(<ore:oreCopper>);
mods.botania.Orechid.removeOre("oreRedstone");
mods.botania.PureDaisy.addRecipe(<minecraft:leaves>, <minecraft:red_flower>, 4);
mods.botania.PureDaisy.addRecipe(<minecraft:beacon>, <minecraft:torch>);
mods.botania.PureDaisy.removeRecipe(<botania:livingwood>);
mods.botania.RuneAltar.addRecipe(<minecraft:apple>, [<minecraft:nether_star>, <minecraft:beacon>, <minecraft:stone>], 40);
mods.botania.RuneAltar.removeRecipe(<botania:rune>);
mods.botania.Lexicon.addCategory("mtdev");
mods.botania.Lexicon.addEntry("deventry", "mtdev", <minecraft:nether_star>);
mods.botania.Lexicon.setEntryKnowledgeType("deventry", "alfheim");
mods.botania.Lexicon.addTextPage("devpage", "deventry", 0);
mods.botania.Lexicon.addRunePage("devpage2", "deventry", 1, [<minecraft:apple>], [[<minecraft:nether_star>, <minecraft:beacon>, <minecraft:stone>]], [40]);
mods.botania.Lexicon.addPetalPage("devpage3", "deventry", 2, [<minecraft:apple>], [[<minecraft:stone>, <minecraft:nether_star>]]);
mods.botania.Lexicon.removeCategory("botania.category.generationFlowers");
mods.botania.Lexicon.removeEntry("botania.entry.relics");
//This lexicon stuff is tiring. So it's unfinished.