From 81fd37e754073461a40e24479387f7db4b5a942c Mon Sep 17 00:00:00 2001 From: "Wizzerinus | Alex K." Date: Mon, 22 Jul 2024 17:19:56 +0300 Subject: [PATCH] Add The Aurorian compatibility (#183) * 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 --- dependencies.gradle | 3 + examples/postInit/theaurorian.groovy | 33 ++++++ gradle.properties | 1 + .../groovyscript/compat/mods/ModSupport.java | 2 + .../mods/theaurorian/MoonlightForge.java | 106 ++++++++++++++++++ .../compat/mods/theaurorian/Scrapper.java | 104 +++++++++++++++++ .../compat/mods/theaurorian/TheAurorian.java | 10 ++ .../assets/groovyscript/lang/en_us.lang | 7 ++ 8 files changed, 266 insertions(+) create mode 100644 examples/postInit/theaurorian.groovy create mode 100644 src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/MoonlightForge.java create mode 100644 src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/Scrapper.java create mode 100644 src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/TheAurorian.java diff --git a/dependencies.gradle b/dependencies.gradle index 4c87e02c5..fd9894af6 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -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], @@ -146,6 +147,8 @@ dependencies { runtimeOnly rfg.deobf("curse.maven:dropt-284973:3758733") } + runtimeOnly 'com.cleanroommc:strip-latest-forge-requirements:1.0' + } minecraft { diff --git a/examples/postInit/theaurorian.groovy b/examples/postInit/theaurorian.groovy new file mode 100644 index 000000000..b4d4e4ad0 --- /dev/null +++ b/examples/postInit/theaurorian.groovy @@ -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() + + diff --git a/gradle.properties b/gradle.properties index 78517c5db..bbc63e236 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 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 5ae966e03..4de31530a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java @@ -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; @@ -105,6 +106,7 @@ public class ModSupport { public static final GroovyContainer ROOTS = new InternalModContainer<>("roots", "Roots 3", Roots::new); public static final GroovyContainer RUSTIC = new InternalModContainer<>("rustic", "Rustic", Rustic::new); public static final GroovyContainer THAUMCRAFT = new InternalModContainer<>("thaumcraft", "Thaumcraft", Thaumcraft::new, "tc", "thaum"); + public static final GroovyContainer THE_AURORIAN = new InternalModContainer<>("theaurorian", "The Aurorian", TheAurorian::new, "aurorian"); public static final GroovyContainer THERMAL_EXPANSION = new InternalModContainer<>("thermalexpansion", "Thermal Expansion", ThermalExpansion::new, "thermal"); public static final GroovyContainer TINKERS_COMPLEMENT = new InternalModContainer<>("tcomplement", "Tinkers Complement", TinkersComplement::new, "tcomp", "tinkerscomplement"); public static final GroovyContainer TINKERS_CONSTRUCT = new InternalModContainer<>("tconstruct", "Tinkers' Construct", TinkersConstruct::new, "ticon", "tinkersconstruct"); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/MoonlightForge.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/MoonlightForge.java new file mode 100644 index 000000000..c0548d99e --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/MoonlightForge.java @@ -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 { + + @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 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 { + + @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; + } + } +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/Scrapper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/Scrapper.java new file mode 100644 index 000000000..c177069dc --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/Scrapper.java @@ -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 { + + @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 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 { + + @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; + } + } +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/TheAurorian.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/TheAurorian.java new file mode 100644 index 000000000..88c979838 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/TheAurorian.java @@ -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(); + +} diff --git a/src/main/resources/assets/groovyscript/lang/en_us.lang b/src/main/resources/assets/groovyscript/lang/en_us.lang index 5e801f3c5..bdbdc22e5 100644 --- a/src/main/resources/assets/groovyscript/lang/en_us.lang +++ b/src/main/resources/assets/groovyscript/lang/en_us.lang @@ -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