generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f7c627
commit ba820dd
Showing
7 changed files
with
187 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/com/cleanroommc/groovyscript/compat/mods/arcanearchives/ArcaneArchives.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
126 changes: 126 additions & 0 deletions
126
src/main/java/com/cleanroommc/groovyscript/compat/mods/arcanearchives/GemCuttingTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters