Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add LazyAE2 compat #168

Merged
merged 4 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final def mod_dependencies = [
'alchemistry-293425:3186612' : [project.debug_alchemistry],
'alchemylib-293426:2761706' : [project.debug_alchemistry],
'shadowfacts-forgelin-248453:2785465' : [project.debug_alchemistry],
'ae2-extended-life-570458:4553942' : [project.debug_applied_energistics_2],
'ae2-extended-life-570458:4553942' : [project.debug_applied_energistics_2, project.debug_lazy_ae2],
'arcane-archives-311357:3057332' : [project.debug_arcane_archives],
'guidebook-253874:2989594' : [project.debug_arcane_archives],
'mystical_lib-277064:3483816' : [project.debug_arcane_archives, project.debug_roots],
Expand Down Expand Up @@ -67,6 +67,8 @@ final def mod_dependencies = [
'mantle-74924:2713386' : [project.debug_inspirations, project.debug_tinkers],
'common-capabilities-247007:3053017' : [project.debug_integrated_dynamics],
'integrated-dynamics-236307:3159505' : [project.debug_integrated_dynamics],
'lazy-ae2-322347:3254160' : [project.debug_lazy_ae2],
'libnine-322344:3509087' : [project.debug_lazy_ae2],
'mekanism-268560:2835175' : [project.debug_mekanism],
'natures-aura-306626:2882138' : [project.debug_natures_aura],
'packmode-278398:2567799' : [project.debug_packmode],
Expand Down
82 changes: 82 additions & 0 deletions examples/postInit/threng.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

// Auto generated groovyscript example file
// MODS_LOADED: threng

println 'mod \'threng\' detected, running script'

// Fluix Aggregation:
// Converts up to 3 input itemstacks into an output itemstack.

mods.threng.aggregator.removeByInput(item('appliedenergistics2:material:45'))
mods.threng.aggregator.removeByOutput(item('appliedenergistics2:material:7'))
// mods.threng.aggregator.removeAll()

mods.threng.aggregator.recipeBuilder()
.input(ore('blockGlass'), item('minecraft:diamond'))
.output(item('minecraft:diamond') * 4)
.register()

mods.threng.aggregator.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:diamond'))
.register()


// Pulse Centrifuge:
// Converts 1 input itemstack into an output itemstack.

mods.threng.centrifuge.removeByInput(item('appliedenergistics2:material'))
mods.threng.centrifuge.removeByOutput(item('appliedenergistics2:material:4'))
// mods.threng.centrifuge.removeAll()

mods.threng.centrifuge.recipeBuilder()
.input(ore('blockGlass'))
.output(item('minecraft:diamond'))
.register()

mods.threng.centrifuge.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:diamond'))
.register()


// Crystal Energization:
// Converts 1 input itemstack into an output itemstack, consuming a set amount of energy.

// mods.threng.energizer.removeByInput(item('appliedenergistics2:material'))
mods.threng.energizer.removeByOutput(item('appliedenergistics2:material:1'))
// mods.threng.energizer.removeAll()

mods.threng.energizer.recipeBuilder()
.input(ore('blockGlass'))
.energy(50)
.output(item('minecraft:diamond'))
.register()

mods.threng.energizer.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.energy(10000)
.output(item('minecraft:diamond'))
.register()


// ME Circuit Etching:
// Converts up to 3 input itemstacks from specific slots into an output itemstack.

mods.threng.etcher.removeByInput(item('minecraft:diamond'))
mods.threng.etcher.removeByOutput(item('appliedenergistics2:material:22'))
// mods.threng.etcher.removeAll()

mods.threng.etcher.recipeBuilder()
.input(ore('blockGlass'))
.top(item('minecraft:diamond'))
.bottom(item('minecraft:clay'))
.output(item('minecraft:diamond') * 5)
.register()

mods.threng.etcher.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:diamond'))
.register()


1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ debug_industrial_craft_2_classic = false
debug_industrial_craft_2_experimental = false
debug_inspirations = false
debug_integrated_dynamics = false
debug_lazy_ae2 = false
debug_mekanism = false
debug_natures_aura = false
debug_packmode = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.cleanroommc.groovyscript.compat.mods.inspirations.Inspirations;
import com.cleanroommc.groovyscript.compat.mods.integrateddynamics.IntegratedDynamics;
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.naturesaura.NaturesAura;
import com.cleanroommc.groovyscript.compat.mods.pyrotech.PyroTech;
Expand Down Expand Up @@ -85,6 +86,7 @@ public class ModSupport implements IDynamicGroovyProperty {
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<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<PyroTech> PYROTECH = new InternalModContainer<>("pyrotech", "Pyrotech", PyroTech::new);
public static final GroovyContainer<Roots> ROOTS = new InternalModContainer<>("roots", "Roots 3", Roots::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.cleanroommc.groovyscript.compat.mods.lazyae2;

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.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import io.github.phantamanta44.libnine.LibNine;
import io.github.phantamanta44.threng.recipe.AggRecipe;
import org.jetbrains.annotations.Nullable;

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

@RegistryDescription
public class Aggregator extends VirtualizedRegistry<AggRecipe> {

@RecipeBuilderDescription(example = {
@Example(".input(ore('blockGlass'), item('minecraft:diamond')).output(item('minecraft:diamond') * 4)"),
@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond'))")
})
public static RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

private static Collection<AggRecipe> recipes() {
return LibNine.PROXY.getRecipeManager().getRecipeList(AggRecipe.class).recipes();
}

@Override
public void onReload() {
removeScripted().forEach(recipes()::remove);
restoreFromBackup().forEach(recipes()::add);
}

public void add(AggRecipe recipe) {
recipes().add(recipe);
addScripted(recipe);
}

public void remove(AggRecipe recipe) {
recipes().remove(recipe);
addBackup(recipe);
}

@MethodDescription(example = @Example("item('appliedenergistics2:material:45')"))
public void removeByInput(IIngredient input) {
recipes().removeIf(recipe -> {
if (recipe.input().getInputs().stream().anyMatch(x -> Arrays.stream(input.getMatchingStacks()).anyMatch(x))) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(example = @Example("item('appliedenergistics2:material:7')"))
public void removeByOutput(IIngredient output) {
recipes().removeIf(recipe -> {
if (output.test(recipe.getOutput().getOutput())) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
recipes().forEach(this::addBackup);
recipes().clear();
}

@Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "3")})
@Property(property = "output", valid = @Comp("1"))
public static class RecipeBuilder extends AbstractRecipeBuilder<AggRecipe> {

@Override
public String getErrorMsg() {
return "Error adding Lazy AE2 Aggregator recipe";
}

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

@Override
@RecipeBuilderRegistrationMethod
public @Nullable AggRecipe register() {
if (!validate()) return null;

AggRecipe recipe = new AggRecipe(input.stream().map(LazyAE2::matchesIIngredient).collect(Collectors.toList()), output.get(0));
ModSupport.LAZYAE2.get().aggregator.add(recipe);
return recipe;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.cleanroommc.groovyscript.compat.mods.lazyae2;

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.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import io.github.phantamanta44.libnine.LibNine;
import io.github.phantamanta44.threng.recipe.PurifyRecipe;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.Collection;

@RegistryDescription
public class Centrifuge extends VirtualizedRegistry<PurifyRecipe> {

@RecipeBuilderDescription(example = {
@Example(".input(ore('blockGlass')).output(item('minecraft:diamond'))"),
@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond'))")
})
public static RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

private static Collection<PurifyRecipe> recipes() {
return LibNine.PROXY.getRecipeManager().getRecipeList(PurifyRecipe.class).recipes();
}

@Override
public void onReload() {
removeScripted().forEach(recipes()::remove);
restoreFromBackup().forEach(recipes()::add);
}

public void add(PurifyRecipe recipe) {
recipes().add(recipe);
addScripted(recipe);
}

public void remove(PurifyRecipe recipe) {
recipes().remove(recipe);
addBackup(recipe);
}

@MethodDescription(example = @Example("item('appliedenergistics2:material')"))
public void removeByInput(IIngredient input) {
recipes().removeIf(recipe -> {
if (Arrays.stream(input.getMatchingStacks()).anyMatch(recipe.input().getMatcher())) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(example = @Example("item('appliedenergistics2:material:4')"))
public void removeByOutput(IIngredient output) {
recipes().removeIf(recipe -> {
if (output.test(recipe.getOutput().getOutput())) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
recipes().forEach(this::addBackup);
recipes().clear();
}

@Property(property = "input", valid = @Comp("1"))
@Property(property = "output", valid = @Comp("1"))
public static class RecipeBuilder extends AbstractRecipeBuilder<PurifyRecipe> {

@Override
public String getErrorMsg() {
return "Error adding Lazy AE2 Centrifuge recipe";
}

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

@Override
@RecipeBuilderRegistrationMethod
public @Nullable PurifyRecipe register() {
if (!validate()) return null;

PurifyRecipe recipe = new PurifyRecipe(LazyAE2.matchesIIngredient(input.get(0)), output.get(0));
ModSupport.LAZYAE2.get().centrifuge.add(recipe);
return recipe;
}
}

}
Loading