Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ dependencies {
deobfProvided 'curse.maven:industrialcraft_classic-242942:3093607'
}

if (project.debug_astral.toBoolean() || project.debug_thaum.toBoolean()) {
if (project.debug_astral.toBoolean() || project.debug_thaum.toBoolean() || project.debug_botania.toBoolean()) {
runtime 'curse.maven:baubles-227083:2518667'
}

Expand Down Expand Up @@ -200,6 +200,12 @@ dependencies {
deobfProvided 'curse.maven:constructs-armory-287683:3174535'
deobfProvided 'curse.maven:tinkers-complement-272671:2843439'
}

if (project.debug_botania.toBoolean()) {
deobfCompile 'curse.maven:botania-225643:3330934'
} else {
deobfProvided 'curse.maven:botania-225643:3330934'
}
}

sourceSets {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ debug_astral = false
debug_blood_magic = false
debug_tinkers = false
debug_extended_crafting = false
debug_botania = false
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.cleanroommc.groovyscript.api.IDynamicGroovyProperty;
import com.cleanroommc.groovyscript.compat.mods.astralsorcery.AstralSorcery;
import com.cleanroommc.groovyscript.compat.mods.bloodmagic.BloodMagic;
import com.cleanroommc.groovyscript.compat.mods.botania.Botania;
import com.cleanroommc.groovyscript.compat.mods.draconicevolution.DraconicEvolution;
import com.cleanroommc.groovyscript.compat.mods.enderio.EnderIO;
import com.cleanroommc.groovyscript.compat.mods.extendedcrafting.ExtendedCrafting;
Expand Down Expand Up @@ -38,6 +39,7 @@ public class ModSupport implements IDynamicGroovyProperty {
public static final Container<EnderIO> ENDER_IO = new Container<>("enderio", "Ender IO", EnderIO::new, "eio");
public static final Container<JustEnoughItems> JEI = new Container<>("jei", "Just Enough Items", JustEnoughItems::new, "hei");
public static final Container<Thaumcraft> THAUMCRAFT = new Container<>("thaumcraft", "Thaumcraft", Thaumcraft::new, "tc", "thaum");
public static final Container<Botania> BOTANIA = new Container<>("botania", "Botania", Botania::new);
public static final Container<Mekanism> MEKANISM = new Container<>("mekanism", "Mekanism", Mekanism::new);
public static final Container<ThermalExpansion> THERMAL_EXPANSION = new Container<>("thermalexpansion", "Thermal Expansion", ThermalExpansion::new, "te", "thermal");
public static final Container<TinkersConstruct> TINKERS_CONSTRUCT = new Container<>("tconstruct", "Tinkers' Construct", TinkersConstruct::new, "ticon", "tinkersconstruct");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.cleanroommc.groovyscript.compat.mods.botania;

import com.cleanroommc.groovyscript.api.GroovyBlacklist;
import com.cleanroommc.groovyscript.api.GroovyLog;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient;
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.recipe.RecipePetals;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Apothecary extends VirtualizedRegistry<RecipePetals> {

public RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

@Override
@GroovyBlacklist
public void onReload() {
removeScripted().forEach(BotaniaAPI.petalRecipes::remove);
BotaniaAPI.petalRecipes.addAll(restoreFromBackup());
}

public RecipePetals add(ItemStack output, IIngredient... inputs) {
RecipePetals recipe = new RecipePetals(output, Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]).toArray());
add(recipe);
return recipe;
}

public void add(RecipePetals recipe) {
if (recipe == null) return;
addScripted(recipe);
BotaniaAPI.petalRecipes.add(recipe);
}

public boolean remove(RecipePetals recipe) {
if (recipe == null) return false;
addBackup(recipe);
return BotaniaAPI.petalRecipes.remove(recipe);
}

public boolean removeByOutput(IIngredient output) {
if (BotaniaAPI.petalRecipes.removeIf(recipe -> {
boolean found = output.test(recipe.getOutput());
if (found) addBackup(recipe);
return found;
})) return true;

GroovyLog.msg("Error removing Botania Apothecary recipe")
.add("could not find recipe with output {}", output)
.error()
.post();
return false;
}

public boolean removeByInput(IIngredient... inputs) {
List<Object> converted = Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]).collect(Collectors.toList());
if (BotaniaAPI.petalRecipes.removeIf(recipe -> {
boolean found = converted.stream().allMatch(o -> recipe.getInputs().stream().anyMatch(i -> o instanceof String ? o.equals(i) : ItemStack.areItemStacksEqual((ItemStack) i, (ItemStack) o)));
if (found) addBackup(recipe);
return found;
})) return true;

GroovyLog.msg("Error removing Botania Apothecary recipe")
.add("could not find recipe with inputs {}", converted)
.error()
.post();
return false;
}

public boolean removeByInputs(IIngredient... inputs) {
return removeByInput(inputs);
}

public void removeAll() {
BotaniaAPI.petalRecipes.forEach(this::addBackup);
BotaniaAPI.petalRecipes.clear();
}

public SimpleObjectStream<RecipePetals> streamRecipes() {
return new SimpleObjectStream<>(BotaniaAPI.petalRecipes).setRemover(this::remove);
}

public class RecipeBuilder extends AbstractRecipeBuilder<RecipePetals> {

@Override
public String getErrorMsg() {
return "Error adding Botania Apothecary recipe";
}

@Override
public void validate(GroovyLog.Msg msg) {
validateFluids(msg, 0, 0, 0, 0);
validateItems(msg, 1, 20, 1, 1);
}

@Override
public @Nullable RecipePetals register() {
if (!validate()) return null;
RecipePetals recipe = new RecipePetals(output.get(0), input.stream().map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]).toArray());
add(recipe);
return recipe;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.cleanroommc.groovyscript.compat.mods.botania;

import com.cleanroommc.groovyscript.brackets.BracketHandlerManager;
import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;

public class Botania extends ModPropertyContainer {

public final ElvenTrade elvenTrade = new ElvenTrade();
public final ManaInfusion manaInfusion = new ManaInfusion();
public final PureDaisy pureDaisy = new PureDaisy();
public final Apothecary apothecary = new Apothecary();
public final Orechid orechid = new Orechid();
public final OrechidIgnem orechidIgnem = new OrechidIgnem();
public final RuneAltar runeAltar = new RuneAltar();
public final Brew brew = new Brew();
public final Lexicon lexicon = new Lexicon();
public final Knowledge knowledge = new Knowledge();
public final Magnet magnet = new Magnet();
public final Flowers flowers = new Flowers();

public Botania() {
addRegistry(elvenTrade);
addRegistry(manaInfusion);
addRegistry(pureDaisy);
addRegistry(apothecary);
addRegistry(orechid);
addRegistry(orechidIgnem);
addRegistry(runeAltar);
addRegistry(brew);
addRegistry(lexicon.category);
addRegistry(lexicon.entry);
addRegistry(lexicon.page);
addRegistry(knowledge);
addRegistry(magnet);
}

public static LexiconCategory getCategory(String name) {
for (LexiconCategory category : BotaniaAPI.getAllCategories())
if (category.getUnlocalizedName().equals(name)) return category;
return null;
}

public static LexiconEntry getEntry(String name) {
for (LexiconEntry entry : BotaniaAPI.getAllEntries())
if (entry.getUnlocalizedName().equals(name)) return entry;
return null;
}

@Override
public void initialize() {
BracketHandlerManager.registerBracketHandler("brew", s -> BotaniaAPI.brewMap.getOrDefault(s, BotaniaAPI.fallbackBrew));
}
}
Loading