Skip to content

Commit

Permalink
add Mystical Agriculture compat (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
WaitingIdly authored Jul 23, 2024
1 parent 4a76dd4 commit 74a7797
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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],
Expand Down
25 changes: 25 additions & 0 deletions examples/postInit/mysticalagriculture.groovy
Original file line number Diff line number Diff line change
@@ -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()


1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,6 +100,7 @@ public class ModSupport {
public static final GroovyContainer<IntegratedDynamics> INTEGRATED_DYNAMICS = new InternalModContainer<>("integrateddynamics", "Integrated Dynamics", IntegratedDynamics::new, "id");
public static final GroovyContainer<JustEnoughItems> JEI = new InternalModContainer<>("jei", "Just Enough Items", JustEnoughItems::new, "hei");
public static final GroovyContainer<Mekanism> MEKANISM = new InternalModContainer<>("mekanism", "Mekanism", Mekanism::new);
public static final GroovyContainer<MysticalAgriculture> MYSTICAL_AGRICULTURE = new InternalModContainer<>("mysticalagriculture", "Mystical Agriculture", MysticalAgriculture::new);
public static final GroovyContainer<LazyAE2> LAZYAE2 = new InternalModContainer<>("threng", "LazyAE2", LazyAE2::new, "lazyae2");
public static final GroovyContainer<NaturesAura> NATURES_AURA = new InternalModContainer<>("naturesaura", "Nature's Aura", NaturesAura::new);
public static final GroovyContainer<PneumaticCraft> PNEUMATIC_CRAFT = new InternalModContainer<>("pneumaticcraft", "PneumaticCraft: Repressurized", PneumaticCraft::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -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();

}
Original file line number Diff line number Diff line change
@@ -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<ReprocessorRecipe> {

@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<ReprocessorRecipe> 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<ReprocessorRecipe> {

// @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;
}
}
}
7 changes: 7 additions & 0 deletions src/main/resources/assets/groovyscript/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 74a7797

Please sign in to comment.