diff --git a/dependencies.gradle b/dependencies.gradle index b69bfd874..ae8927f40 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -59,7 +59,7 @@ final def mod_dependencies = [ 'dummycore-unofficial-266491:2611426' : [project.debug_essentialcraft_4], 'cyclops-core-232758:3159497' : [project.debug_evilcraft, project.debug_integrated_dynamics], 'evilcraft-74610:2811267' : [project.debug_evilcraft], - 'cucumber-272335:2645867' : [project.debug_extended_crafting], + 'cucumber-272335:2645867' : [project.debug_extended_crafting, project.debug_mystical_agriculture], 'extended-crafting-nomifactory-edition-398267:3613140': [project.debug_extended_crafting], 'extra-utilities-2-225561:2678374' : [project.debug_extra_utilities_2], 'forestry-59751:2918418' : [project.debug_forestry], @@ -77,6 +77,7 @@ final def mod_dependencies = [ 'lazy-ae2-322347:3254160' : [project.debug_lazy_ae2], 'libnine-322344:3509087' : [project.debug_lazy_ae2], 'mekanism-268560:2835175' : [project.debug_mekanism], + 'mystical_agriculture-246640:2704562' : [project.debug_mystical_agriculture], 'natures-aura-306626:2882138' : [project.debug_natures_aura], 'packmode-278398:2567799' : [project.debug_packmode], 'pneumaticcraft-repressurized-281849:2978408' : [project.debug_pneumaticcraft], diff --git a/examples/postInit/mysticalagriculture.groovy b/examples/postInit/mysticalagriculture.groovy new file mode 100644 index 000000000..6d7021909 --- /dev/null +++ b/examples/postInit/mysticalagriculture.groovy @@ -0,0 +1,25 @@ + +// Auto generated groovyscript example file +// MODS_LOADED: mysticalagriculture + +println 'mod \'mysticalagriculture\' detected, running script' + +// Seed Reprocessor: +// Converts an input itemstack into an output itemstack, taking a set amount of time based on the machine and consuming +// fuel. + +mods.mysticalagriculture.reprocessor.removeByInput(item('mysticalagriculture:stone_seeds')) +mods.mysticalagriculture.reprocessor.removeByOutput(item('mysticalagriculture:dirt_essence')) +// mods.mysticalagriculture.reprocessor.removeAll() + +mods.mysticalagriculture.reprocessor.recipeBuilder() + .input(item('minecraft:clay')) + .output(item('minecraft:diamond') * 3) + .register() + +mods.mysticalagriculture.reprocessor.recipeBuilder() + .input(item('minecraft:diamond')) + .output(item('minecraft:gold_ingot')) + .register() + + diff --git a/gradle.properties b/gradle.properties index e4e39a6e2..00c17accd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -44,6 +44,7 @@ debug_inspirations = false debug_integrated_dynamics = false debug_lazy_ae2 = false debug_mekanism = false +debug_mystical_agriculture = false debug_natures_aura = false debug_packmode = false debug_pneumaticcraft = false diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java index 5825615ae..c73bc0458 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java @@ -35,6 +35,7 @@ import com.cleanroommc.groovyscript.compat.mods.jei.JustEnoughItems; import com.cleanroommc.groovyscript.compat.mods.lazyae2.LazyAE2; import com.cleanroommc.groovyscript.compat.mods.mekanism.Mekanism; +import com.cleanroommc.groovyscript.compat.mods.mysticalagriculture.MysticalAgriculture; import com.cleanroommc.groovyscript.compat.mods.naturesaura.NaturesAura; import com.cleanroommc.groovyscript.compat.mods.pneumaticcraft.PneumaticCraft; import com.cleanroommc.groovyscript.compat.mods.prodigytech.ProdigyTech; @@ -99,6 +100,7 @@ public class ModSupport { public static final GroovyContainer INTEGRATED_DYNAMICS = new InternalModContainer<>("integrateddynamics", "Integrated Dynamics", IntegratedDynamics::new, "id"); public static final GroovyContainer JEI = new InternalModContainer<>("jei", "Just Enough Items", JustEnoughItems::new, "hei"); public static final GroovyContainer MEKANISM = new InternalModContainer<>("mekanism", "Mekanism", Mekanism::new); + public static final GroovyContainer MYSTICAL_AGRICULTURE = new InternalModContainer<>("mysticalagriculture", "Mystical Agriculture", MysticalAgriculture::new); public static final GroovyContainer LAZYAE2 = new InternalModContainer<>("threng", "LazyAE2", LazyAE2::new, "lazyae2"); public static final GroovyContainer NATURES_AURA = new InternalModContainer<>("naturesaura", "Nature's Aura", NaturesAura::new); public static final GroovyContainer PNEUMATIC_CRAFT = new InternalModContainer<>("pneumaticcraft", "PneumaticCraft: Repressurized", PneumaticCraft::new); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mysticalagriculture/MysticalAgriculture.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mysticalagriculture/MysticalAgriculture.java new file mode 100644 index 000000000..cc7ba1834 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mysticalagriculture/MysticalAgriculture.java @@ -0,0 +1,9 @@ +package com.cleanroommc.groovyscript.compat.mods.mysticalagriculture; + +import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; + +public class MysticalAgriculture extends GroovyPropertyContainer { + + public Reprocessor reprocessor = new Reprocessor(); + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mysticalagriculture/Reprocessor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mysticalagriculture/Reprocessor.java new file mode 100644 index 000000000..480f1c346 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mysticalagriculture/Reprocessor.java @@ -0,0 +1,146 @@ +package com.cleanroommc.groovyscript.compat.mods.mysticalagriculture; + +import com.blakebr0.mysticalagriculture.crafting.ReprocessorManager; +import com.blakebr0.mysticalagriculture.crafting.ReprocessorRecipe; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import net.minecraft.item.ItemStack; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class Reprocessor extends VirtualizedRegistry { + + @RecipeBuilderDescription(example = { + @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 3)"), + @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot'))") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + public void onReload() { + ReprocessorManager.getRecipes().removeAll(removeScripted()); + ReprocessorManager.getRecipes().addAll(restoreFromBackup()); + } + +// public ReprocessorRecipe add(IIngredient input, ItemStack output, int amount) { +// return add(input, output, amount, false); +// } + + public ReprocessorRecipe add(IIngredient input, ItemStack output/*, int amount, boolean exact*/) { + return recipeBuilder() +// .exact(exact) +// .amount(amount) + .input(input) + .output(output) + .register(); + } + + public void add(ReprocessorRecipe recipe) { + if (recipe == null) return; + addScripted(recipe); + ReprocessorManager.getRecipes().add(recipe); + } + + public boolean remove(ReprocessorRecipe recipe) { + if (recipe == null) return false; + addBackup(recipe); + ReprocessorManager.getRecipes().remove(recipe); + return true; + } + + @MethodDescription(example = @Example("item('mysticalagriculture:stone_seeds')")) + public boolean removeByInput(IIngredient input) { + return ReprocessorManager.getRecipes().removeIf(recipe -> { + if (input.test(recipe.getInput())) { + addBackup(recipe); + return true; + } + return false; + }); + } + + @MethodDescription(example = @Example("item('mysticalagriculture:dirt_essence')")) + public boolean removeByOutput(IIngredient output) { + return ReprocessorManager.getRecipes().removeIf(recipe -> { + if (output.test(recipe.getOutput())) { + addBackup(recipe); + return true; + } + return false; + }); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + ReprocessorManager.getRecipes().forEach(this::addBackup); + ReprocessorManager.getRecipes().clear(); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(ReprocessorManager.getRecipes()) + .setRemover(this::remove); + } + + @Property(property = "input", valid = @Comp("1")) + @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) + public static class RecipeBuilder extends AbstractRecipeBuilder { + +// @Property(valid = @Comp(type = Comp.Type.GT, value = "0"), defaultValue = "1") +// private int amount = 1; +// @Property +// private boolean exact; +// +// @RecipeBuilderMethodDescription +// public RecipeBuilder amount(int amount) { +// this.amount = amount; +// return this; +// } +// +// @RecipeBuilderMethodDescription +// public RecipeBuilder exact() { +// this.exact = !exact; +// return this; +// } +// +// @RecipeBuilderMethodDescription +// public RecipeBuilder exact(boolean exact) { +// this.exact = exact; +// return this; +// } + + @Override + public String getErrorMsg() { + return "Error adding Mystical Agriculture Reprocessor recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 1, 1, 1, 1); + validateFluids(msg); +// msg.add(amount <= 0, "amount must be greater than 0, yet it was {}", amount); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable ReprocessorRecipe register() { + if (!validate()) return null; + ReprocessorRecipe recipe = null; + for (ItemStack matchingStack : input.get(0).getMatchingStacks()) { +// recipe = new ReprocessorRecipe(output.get(0), amount, matchingStack, exact); + recipe = new ReprocessorRecipe(output.get(0), 1, matchingStack, false); + ModSupport.MYSTICAL_AGRICULTURE.get().reprocessor.add(recipe); + } + return recipe; + } + } +} diff --git a/src/main/resources/assets/groovyscript/lang/en_us.lang b/src/main/resources/assets/groovyscript/lang/en_us.lang index 41af4de87..039c0e88e 100644 --- a/src/main/resources/assets/groovyscript/lang/en_us.lang +++ b/src/main/resources/assets/groovyscript/lang/en_us.lang @@ -1307,6 +1307,13 @@ groovyscript.wiki.mekanism.washer.description=Converts an input gasstack into an groovyscript.wiki.mekanism.washer.add=Adds recipes in the format `input`, `output` +# Mystical Agriculture +groovyscript.wiki.mysticalagriculture.reprocessor.title=Seed Reprocessor +groovyscript.wiki.mysticalagriculture.reprocessor.description=Converts an input itemstack into an output itemstack, taking a set amount of time based on the machine and consuming fuel. +#groovyscript.wiki.mysticalagriculture.reprocessor.exact.value=Sets an unknown boolean. Doesn't appear to have an effect +#groovyscript.wiki.mysticalagriculture.reprocessor.amount.value=Sets the amount of items required to complete the recipe in the normal Reprocessor. Doesn't work + + # Nature's Aura groovyscript.wiki.naturesaura.altar.title=Natural Altar Infusion groovyscript.wiki.naturesaura.altar.description=Converts an input itemstack into an itemstack in a multiblock structure, with an optional catalyst block, costing aura and taking a configurable duration.