Skip to content

Commit

Permalink
arcane archives (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
WaitingIdly authored Mar 28, 2024
1 parent 6f7c627 commit ba820dd
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,28 @@ dependencies {
runtimeOnly rfg.deobf('curse.maven:immersive_engineering-231951:2974106')
}

compileOnly rfg.deobf('curse.maven:patchouli-306770:3162874')
compileOnly rfg.deobf('curse.maven:mystical_lib-277064:3483816')
if (project.debug_roots.toBoolean() || project.debug_arcane_archives.toBoolean()) {
runtimeOnly rfg.deobf('curse.maven:mystical_lib-277064:3483816')
}

compileOnly rfg.deobf('curse.maven:patchouli-306770:3162874')
compileOnly rfg.deobf('curse.maven:mystical_world-282940:3460961')
compileOnly rfg.deobf('curse.maven:roots-246183:3905074')
if (project.debug_roots.toBoolean()) {
runtimeOnly rfg.deobf('curse.maven:patchouli-306770:3162874')
runtimeOnly rfg.deobf('curse.maven:mystical_lib-277064:3483816')
runtimeOnly rfg.deobf('curse.maven:mystical_world-282940:3460961')
runtimeOnly rfg.deobf('curse.maven:roots-246183:3905074')
}

// gigaherz.lirelent.guidebook:Guidebook-1.12.2:2.9.1.s5
compileOnly rfg.deobf('curse.maven:guidebook-253874:2989594')
compileOnly rfg.deobf('curse.maven:arcane-archives-311357:3057332')
if (project.debug_arcane_archives.toBoolean()) {
runtimeOnly rfg.deobf('curse.maven:guidebook-253874:2989594')
runtimeOnly rfg.deobf('curse.maven:arcane-archives-311357:3057332')
}

compileOnly rfg.deobf('curse.maven:thaumcraft-223628:2629023')
if (project.debug_thaum.toBoolean()) {
runtimeOnly rfg.deobf('curse.maven:baubles-227083:2518667')
Expand Down
25 changes: 25 additions & 0 deletions examples/postInit/arcanearchives.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

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

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

// Gem Cutting Table:
// Converts any number of itemstacks into a single output itemstack via selecting the desired output itemstack in the GUI.

mods.arcanearchives.gem_cutting_table.removeByInput(item('minecraft:gold_nugget'))
mods.arcanearchives.gem_cutting_table.removeByOutput(item('arcanearchives:shaped_quartz'))
// mods.arcanearchives.gem_cutting_table.removeAll()

mods.arcanearchives.gem_cutting_table.recipeBuilder()
.name('clay_craft')
.input(item('minecraft:stone') * 64)
.output(item('minecraft:clay'))
.register()

mods.arcanearchives.gem_cutting_table.recipeBuilder()
.input(item('minecraft:stone'),item('minecraft:gold_ingot'),item('minecraft:gold_nugget'))
.output(item('minecraft:clay') * 4)
.register()


1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ debug_adv_mortars = false
debug_aether = false
debug_alchemistry = false
debug_applied_energistics_2 = false
debug_arcane_archives = false
debug_astral = false
debug_avaritia = false
debug_better_with_mods = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.cleanroommc.groovyscript.compat.mods.aetherlegacy.Aether;
import com.cleanroommc.groovyscript.compat.mods.alchemistry.Alchemistry;
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.avaritia.Avaritia;
import com.cleanroommc.groovyscript.compat.mods.betterwithmods.BetterWithMods;
Expand Down Expand Up @@ -61,6 +62,7 @@ public class ModSupport implements IDynamicGroovyProperty {
public static final GroovyContainer<Aether> AETHER = new InternalModContainer<>("aether_legacy", "Aether Legacy", Aether::new, "aether");
public static final GroovyContainer<Alchemistry> ALCHEMISTRY = new InternalModContainer<>("alchemistry", "Alchemistry", Alchemistry::new);
public static final GroovyContainer<AppliedEnergistics2> APPLIED_ENERGISTICS_2 = new InternalModContainer<>("appliedenergistics2", "Applied Energistics 2", AppliedEnergistics2::new, "ae2");
public static final GroovyContainer<ArcaneArchives> ARCANE_ARCHIVES = new InternalModContainer<>("arcanearchives", "Arcane Archives", ArcaneArchives::new);
public static final GroovyContainer<AstralSorcery> ASTRAL_SORCERY = new InternalModContainer<>("astralsorcery", "Astral Sorcery", AstralSorcery::new, "astral");
public static final GroovyContainer<Avaritia> AVARITIA = new InternalModContainer<>("avaritia", "Avaritia", Avaritia::new);
public static final GroovyContainer<BetterWithMods> BETTER_WITH_MODS = new InternalModContainer<>("betterwithmods", "Better With Mods", BetterWithMods::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.cleanroommc.groovyscript.compat.mods.arcanearchives;

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

public class ArcaneArchives extends ModPropertyContainer {

public final GemCuttingTable gemCuttingTable = new GemCuttingTable();

public ArcaneArchives() {
addRegistry(gemCuttingTable);
}

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

import com.aranaira.arcanearchives.api.IGCTRecipe;
import com.aranaira.arcanearchives.recipe.IngredientStack;
import com.aranaira.arcanearchives.recipe.gct.GCTRecipe;
import com.aranaira.arcanearchives.recipe.gct.GCTRecipeList;
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.Alias;
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import net.minecraft.item.crafting.Ingredient;
import org.jetbrains.annotations.Nullable;

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

@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.arcanearchives.gem_cutting_table.note0", type = Admonition.Type.WARNING))
public class GemCuttingTable extends VirtualizedRegistry<IGCTRecipe> {

public GemCuttingTable() {
super(Alias.generateOfClass(GemCuttingTable.class).and("GCT", "gct"));
}

@RecipeBuilderDescription(example = {
@Example(".name('clay_craft').input(item('minecraft:stone') * 64).output(item('minecraft:clay'))"),
@Example(".input(item('minecraft:stone'),item('minecraft:gold_ingot'),item('minecraft:gold_nugget')).output(item('minecraft:clay') * 4)")
})
public RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

@Override
public void onReload() {
removeScripted().forEach(GCTRecipeList.instance::removeRecipe);
restoreFromBackup().forEach(GCTRecipeList.instance::addRecipe);
}

public void add(IGCTRecipe recipe) {
if (recipe == null) return;
GCTRecipeList.instance.addRecipe(recipe);
addScripted(recipe);
}

public boolean remove(IGCTRecipe recipe) {
if (recipe == null) return false;
GCTRecipeList.instance.removeRecipe(recipe);
addBackup(recipe);
return true;
}

@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('minecraft:gold_nugget')"))
public boolean removeByInput(IIngredient input) {
return GCTRecipeList.instance.getRecipes().values().removeIf(recipe -> {
boolean found = recipe.getIngredients().stream()
.map(IngredientStack::getIngredient)
.map(Ingredient::getMatchingStacks)
.flatMap(Arrays::stream)
.anyMatch(input);
if (found) {
addBackup(recipe);
}
return found;
});
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('arcanearchives:shaped_quartz')"))
public boolean removeByOutput(IIngredient output) {
return GCTRecipeList.instance.getRecipes().values().removeIf(recipe -> {
boolean matches = output.test(recipe.getRecipeOutput());
if (matches) {
addBackup(recipe);
}
return matches;
});
}

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
public SimpleObjectStream<IGCTRecipe> streamRecipes() {
return new SimpleObjectStream<>(GCTRecipeList.instance.getRecipeList())
.setRemover(this::remove);
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
public void removeAll() {
for (IGCTRecipe recipe : GCTRecipeList.instance.getRecipeList()) {
addBackup(recipe);
GCTRecipeList.instance.removeRecipe(recipe);
}
}

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

@Override
public String getRecipeNamePrefix() {
return "groovyscript_gem_cutting_table_";
}

@Override
public String getErrorMsg() {
return "Error adding Arcane Archives Gem Cutting Table recipe";
}

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

@Override
@RecipeBuilderRegistrationMethod
public @Nullable IGCTRecipe register() {
if (!validate()) return null;
IGCTRecipe recipe = new GCTRecipe(name, output.get(0), input.stream().map(x -> new IngredientStack(x.toMcIngredient(), x.getAmount())).collect(Collectors.toList()));
ModSupport.ARCANE_ARCHIVES.get().gemCuttingTable.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 @@ -238,6 +238,13 @@ groovyscript.wiki.appliedenergistics2.spatial.description=Either the class itsel
groovyscript.wiki.appliedenergistics2.spatial.add=Adds the given class to the list of allowed TileEntities to be moved by Spatial Storage
groovyscript.wiki.appliedenergistics2.spatial.remove=Removes the given class from the list of allowed TileEntities to be moved by Spatial Storage


# Arcane Archives
groovyscript.wiki.arcanearchives.gem_cutting_table.title=Gem Cutting Table
groovyscript.wiki.arcanearchives.gem_cutting_table.description=Converts any number of itemstacks into a single output itemstack via selecting the desired output itemstack in the GUI.
groovyscript.wiki.arcanearchives.gem_cutting_table.note0=While more than 8 items can function as the input of a Stygian Iron Anvil recipe, only the first 8 are shown in JEI.


# Astral Sorcery
groovyscript.wiki.astralsorcery.aevitas_perk_registry.title=Aevitas Perk Registry
groovyscript.wiki.astralsorcery.aevitas_perk_registry.description=Having the Stone Enrichment perk will convert nearby stone blocks into random ores.
Expand Down

0 comments on commit ba820dd

Please sign in to comment.