Skip to content

Commit

Permalink
Add The Aurorian compatibility (#183)
Browse files Browse the repository at this point in the history
* aurorian: implemented compatibility

* aurorian: add an alias

* aurorian: fixed pr things

* aurorian: extract remove() into its own method

* aurorian: input is no longer named output

* aurorian: add removeByInput description
  • Loading branch information
Wizzerinus authored Jul 22, 2024
1 parent 6bd82e7 commit 81fd37e
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ final def mod_dependencies = [
'mystical_lib-277064:3483816' : [project.debug_arcane_archives, project.debug_roots],
'astralsorcery-sorcery-241721:3044416' : [project.debug_astral],
'baubles-227083:2518667' : [project.debug_astral, project.debug_botania, project.debug_thaum, project.debug_essentialcraft_4],
'the-aurorian-352137:4981736' : [project.debug_aurorian],
'avaritia_1_10-261348:3143349' : [project.debug_avaritia],
'bwm-core-294335:2624990' : [project.debug_better_with_mods],
'bwm-suite-246760:3289033' : [project.debug_better_with_mods],
Expand Down Expand Up @@ -146,6 +147,8 @@ dependencies {
runtimeOnly rfg.deobf("curse.maven:dropt-284973:3758733")
}

runtimeOnly 'com.cleanroommc:strip-latest-forge-requirements:1.0'

}

minecraft {
Expand Down
33 changes: 33 additions & 0 deletions examples/postInit/theaurorian.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

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

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

// Moonlight Forge:
// Combines two items to get a third item. Only works at night, and works faster the higher it is placed in the world.

mods.theaurorian.moonlight_forge.removeByInput(item('theaurorian:moonstonesword'), item('theaurorian:aurorianiteingot'))
mods.theaurorian.moonlight_forge.removeByOutput(item('theaurorian:queenschipper'))
// mods.theaurorian.moonlight_forge.removeAll()

mods.theaurorian.moonlight_forge.recipeBuilder()
.input(item('minecraft:stone_sword'), item('minecraft:diamond'))
.output(item('minecraft:diamond_sword'))
.register()


// Scrapper:
// Turns an input item into an output item. Can be sped up by placing a Crystal on top of it. The crystal has a chance to
// break every time a recipe is executed.

mods.theaurorian.scrapper.removeByInput(item('minecraft:iron_sword'))
mods.theaurorian.scrapper.removeByOutput(item('theaurorian:scrapaurorianite'))
// mods.theaurorian.scrapper.removeAll()

mods.theaurorian.scrapper.recipeBuilder()
.input(item('minecraft:stone_sword'))
.output(item('minecraft:cobblestone'))
.register()


1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ debug_alchemistry = false
debug_applied_energistics_2 = false
debug_arcane_archives = false
debug_astral = false
debug_aurorian = false
debug_avaritia = false
debug_better_with_mods = false
debug_blood_magic = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.cleanroommc.groovyscript.compat.mods.appliedenergistics2.AppliedEnergistics2;
import com.cleanroommc.groovyscript.compat.mods.arcanearchives.ArcaneArchives;
import com.cleanroommc.groovyscript.compat.mods.astralsorcery.AstralSorcery;
import com.cleanroommc.groovyscript.compat.mods.theaurorian.TheAurorian;
import com.cleanroommc.groovyscript.compat.mods.avaritia.Avaritia;
import com.cleanroommc.groovyscript.compat.mods.betterwithmods.BetterWithMods;
import com.cleanroommc.groovyscript.compat.mods.bloodmagic.BloodMagic;
Expand Down Expand Up @@ -105,6 +106,7 @@ public class ModSupport {
public static final GroovyContainer<Roots> ROOTS = new InternalModContainer<>("roots", "Roots 3", Roots::new);
public static final GroovyContainer<Rustic> RUSTIC = new InternalModContainer<>("rustic", "Rustic", Rustic::new);
public static final GroovyContainer<Thaumcraft> THAUMCRAFT = new InternalModContainer<>("thaumcraft", "Thaumcraft", Thaumcraft::new, "tc", "thaum");
public static final GroovyContainer<TheAurorian> THE_AURORIAN = new InternalModContainer<>("theaurorian", "The Aurorian", TheAurorian::new, "aurorian");
public static final GroovyContainer<ThermalExpansion> THERMAL_EXPANSION = new InternalModContainer<>("thermalexpansion", "Thermal Expansion", ThermalExpansion::new, "thermal");
public static final GroovyContainer<TinkersComplement> TINKERS_COMPLEMENT = new InternalModContainer<>("tcomplement", "Tinkers Complement", TinkersComplement::new, "tcomp", "tinkerscomplement");
public static final GroovyContainer<TinkersConstruct> TINKERS_CONSTRUCT = new InternalModContainer<>("tconstruct", "Tinkers' Construct", TinkersConstruct::new, "ticon", "tinkersconstruct");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.cleanroommc.groovyscript.compat.mods.theaurorian;

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 com.shiroroku.theaurorian.Recipes.MoonlightForgeRecipe;
import com.shiroroku.theaurorian.Recipes.MoonlightForgeRecipeHandler;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;

@RegistryDescription
public class MoonlightForge extends VirtualizedRegistry<MoonlightForgeRecipe> {

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

@Override
public void onReload() {
restoreFromBackup().forEach(MoonlightForgeRecipeHandler::addRecipe);
removeScripted().forEach(r -> MoonlightForgeRecipeHandler.allRecipes.removeIf(u -> u.equals(r)));
}

public void add(MoonlightForgeRecipe recipe) {
addScripted(recipe);
MoonlightForgeRecipeHandler.addRecipe(recipe);
}

public boolean remove(MoonlightForgeRecipe recipe) {
return MoonlightForgeRecipeHandler.allRecipes.removeIf(r -> {
if (r.equals(recipe)) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(example = @Example("item('theaurorian:moonstonesword'), item('theaurorian:aurorianiteingot')"))
public boolean removeByInput(IIngredient input, IIngredient catalyst) {
return MoonlightForgeRecipeHandler.allRecipes.removeIf(r -> {
if (input.test(r.getInput1()) && catalyst.test(r.getInput2())) {
addBackup(r);
return true;
}
return false;
});
}

@MethodDescription(example = @Example("item('theaurorian:queenschipper')"))
public boolean removeByOutput(IIngredient output) {
return MoonlightForgeRecipeHandler.allRecipes.removeIf(r -> {
if (output.test(r.getOutput())) {
addBackup(r);
return true;
}
return false;
});
}

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

@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<MoonlightForgeRecipe> streamRecipes() {
return new SimpleObjectStream<>(MoonlightForgeRecipeHandler.allRecipes).setRemover(this::remove);
}

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

@Override
public String getErrorMsg() {
return "Error adding Moonlight Forge recipe";
}

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

@Override
@RecipeBuilderRegistrationMethod
public @Nullable MoonlightForgeRecipe register() {
if (!validate()) return null;
MoonlightForgeRecipe recipe = null;
for (ItemStack input1 : input.get(0).getMatchingStacks()) {
for (ItemStack input2 : input.get(1).getMatchingStacks()) {
recipe = new MoonlightForgeRecipe(input1, input2, output.get(0));
ModSupport.THE_AURORIAN.get().moonlightForge.add(recipe);
}
}
return recipe;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.cleanroommc.groovyscript.compat.mods.theaurorian;

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 com.shiroroku.theaurorian.Recipes.ScrapperRecipe;
import com.shiroroku.theaurorian.Recipes.ScrapperRecipeHandler;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;

@RegistryDescription
public class Scrapper extends VirtualizedRegistry<ScrapperRecipe> {

@RecipeBuilderDescription(example = @Example(".input(item('minecraft:stone_sword')).output(item('minecraft:cobblestone'))"))
public RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

@Override
public void onReload() {
restoreFromBackup().forEach(ScrapperRecipeHandler::addRecipe);
removeScripted().forEach(r -> ScrapperRecipeHandler.allRecipes.removeIf(u -> u.equals(r)));
}

public void add(ScrapperRecipe recipe) {
addScripted(recipe);
ScrapperRecipeHandler.addRecipe(recipe);
}

public boolean remove(ScrapperRecipe recipe) {
return ScrapperRecipeHandler.allRecipes.removeIf(r -> {
if (r.equals(recipe)) {
addBackup(recipe);
return true;
}
return false;
});
}

@MethodDescription(example = @Example("item('minecraft:iron_sword')"))
public boolean removeByInput(IIngredient input) {
return ScrapperRecipeHandler.allRecipes.removeIf(r -> {
if (input.test(r.getInput())) {
addBackup(r);
return true;
}
return false;
});
}

@MethodDescription(example = @Example("item('theaurorian:scrapaurorianite')"))
public boolean removeByOutput(IIngredient output) {
return ScrapperRecipeHandler.allRecipes.removeIf(r -> {
if (output.test(r.getOutput())) {
addBackup(r);
return true;
}
return false;
});
}

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

@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<ScrapperRecipe> streamRecipes() {
return new SimpleObjectStream<>(ScrapperRecipeHandler.allRecipes).setRemover(this::remove);
}

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

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

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

@Override
@RecipeBuilderRegistrationMethod
public @Nullable ScrapperRecipe register() {
if (!validate()) return null;
ScrapperRecipe recipe = null;
for (ItemStack input1 : input.get(0).getMatchingStacks()) {
recipe = new ScrapperRecipe(input1, output.get(0));
ModSupport.THE_AURORIAN.get().scrapper.add(recipe);
}
return recipe;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.cleanroommc.groovyscript.compat.mods.theaurorian;

import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer;

public class TheAurorian extends GroovyPropertyContainer {

public final Scrapper scrapper = new Scrapper();
public final MoonlightForge moonlightForge = new MoonlightForge();

}
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 @@ -1835,6 +1835,13 @@ groovyscript.wiki.thaumcraft.warp.description=Determines if holding an item or e
groovyscript.wiki.thaumcraft.warp.addWarp=Adds Warp to the given item in the format `item`, `amount`
groovyscript.wiki.thaumcraft.warp.removeWarp=Removes Warp from the given item

# The Aurorian
groovyscript.wiki.theaurorian.moonlight_forge.title=Moonlight Forge
groovyscript.wiki.theaurorian.moonlight_forge.description=Combines two items to get a third item. Only works at night, and works faster the higher it is placed in the world.
groovyscript.wiki.theaurorian.moonlight_forge.removeByInput=Removes a recipe by the input item and the catalyst item
groovyscript.wiki.theaurorian.scrapper.title=Scrapper
groovyscript.wiki.theaurorian.scrapper.description=Turns an input item into an output item. Can be sped up by placing a Crystal on top of it. The crystal has a chance to break every time a recipe is executed.

# Thermal Expansion
groovyscript.wiki.thermalexpansion.energy.value=Sets the energy cost of the recipe

Expand Down

0 comments on commit 81fd37e

Please sign in to comment.