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.
* add natures aura * dont need to store the ResourceLocation
- Loading branch information
1 parent
b31f869
commit 8ea4da7
Showing
10 changed files
with
837 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,140 @@ | ||
|
||
// Auto generated groovyscript example file | ||
// MODS_LOADED: naturesaura | ||
|
||
println 'mod \'naturesaura\' detected, running script' | ||
|
||
// Natural Altar Infusion: | ||
// Converts an input itemstack into an itemstack in a multiblock structure, with an optional catalyst block, costing aura | ||
// and taking a configurable duration. | ||
|
||
mods.naturesaura.altar.removeByCatalyst(item('naturesaura:crushing_catalyst')) | ||
mods.naturesaura.altar.removeByInput(item('minecraft:rotten_flesh')) | ||
mods.naturesaura.altar.removeByName(resource('naturesaura:infused_iron')) | ||
mods.naturesaura.altar.removeByOutput(item('minecraft:soul_sand')) | ||
// mods.naturesaura.altar.removeAll() | ||
|
||
mods.naturesaura.altar.recipeBuilder() | ||
.name('demo') | ||
.input(item('minecraft:clay')) | ||
.catalyst(item('minecraft:clay')) | ||
.output(item('minecraft:diamond')) | ||
.aura(100) | ||
.time(100) | ||
.register() | ||
|
||
mods.naturesaura.altar.recipeBuilder() | ||
.name(resource('example:demo')) | ||
.input(item('minecraft:clay')) | ||
.output(item('minecraft:gold_ingot') * 8) | ||
.aura(30) | ||
.time(5) | ||
.register() | ||
|
||
mods.naturesaura.altar.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:diamond')) | ||
.catalyst(item('minecraft:clay')) | ||
.aura(50) | ||
.time(100) | ||
.register() | ||
|
||
|
||
// Offering to the Gods: | ||
// Converts up to 16 times the input itemstack into output itemstacks by consuming a catalyst item from the ground in a | ||
// multiblock structure. | ||
|
||
// mods.naturesaura.offering.removeByCatalyst(item('naturesaura:calling_spirit')) | ||
mods.naturesaura.offering.removeByInput(item('minecraft:nether_star')) | ||
mods.naturesaura.offering.removeByName(resource('naturesaura:token_euphoria')) | ||
mods.naturesaura.offering.removeByOutput(item('naturesaura:sky_ingot')) | ||
// mods.naturesaura.offering.removeAll() | ||
|
||
mods.naturesaura.offering.recipeBuilder() | ||
.name('demo') | ||
.input(item('minecraft:diamond')) | ||
.catalyst(item('minecraft:clay')) | ||
.output(item('minecraft:gold_ingot') * 8) | ||
.register() | ||
|
||
mods.naturesaura.offering.recipeBuilder() | ||
.name(resource('example:demo')) | ||
.input(item('minecraft:clay')) | ||
.catalyst(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:diamond') * 8) | ||
.register() | ||
|
||
mods.naturesaura.offering.recipeBuilder() | ||
.input(item('minecraft:gold_ingot') * 10) | ||
.catalyst(item('minecraft:diamond')) | ||
.output(item('minecraft:clay')) | ||
.register() | ||
|
||
|
||
// Ritual of the Forest: | ||
// Converts multiple input items into an output itemstack after a duration when a sapling grows in the middle of a | ||
// multiblock structure. | ||
|
||
mods.naturesaura.ritual.removeByInput(item('naturesaura:infused_stone')) | ||
mods.naturesaura.ritual.removeByName(resource('naturesaura:eye_improved')) | ||
mods.naturesaura.ritual.removeByOutput(item('naturesaura:eye')) | ||
mods.naturesaura.ritual.removeBySapling(item('minecraft:sapling:3')) | ||
// mods.naturesaura.ritual.removeAll() | ||
|
||
mods.naturesaura.ritual.recipeBuilder() | ||
.name('demo') | ||
.input(item('minecraft:clay')) | ||
.output(item('minecraft:diamond')) | ||
.time(100) | ||
.sapling(item('minecraft:sapling:1')) | ||
.register() | ||
|
||
mods.naturesaura.ritual.recipeBuilder() | ||
.name(resource('example:demo')) | ||
.input(item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay')) | ||
.output(item('minecraft:gold_ingot')) | ||
.time(15) | ||
.sapling(item('minecraft:sapling:1')) | ||
.register() | ||
|
||
mods.naturesaura.ritual.recipeBuilder() | ||
.input(item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay')) | ||
.output(item('minecraft:diamond') * 16) | ||
.time(20) | ||
.sapling(item('minecraft:sapling:3')) | ||
.register() | ||
|
||
|
||
// Altar of Birthing: | ||
// Converts multiple input itemstacks into a summoned entity, costing aura and taking time. | ||
|
||
mods.naturesaura.spawning.removeByEntity(entity('minecraft:polar_bear')) | ||
mods.naturesaura.spawning.removeByEntity(resource('minecraft:cave_spider')) | ||
mods.naturesaura.spawning.removeByInput(item('minecraft:bone')) | ||
mods.naturesaura.spawning.removeByName(resource('naturesaura:cow')) | ||
// mods.naturesaura.spawning.removeAll() | ||
|
||
mods.naturesaura.spawning.recipeBuilder() | ||
.name('demo') | ||
.input(item('minecraft:clay')) | ||
.entity(entity('minecraft:bat')) | ||
.aura(100) | ||
.time(100) | ||
.register() | ||
|
||
mods.naturesaura.spawning.recipeBuilder() | ||
.name(resource('example:demo')) | ||
.input(item('minecraft:mutton')) | ||
.entity(entity('minecraft:wolf')) | ||
.aura(30) | ||
.time(5) | ||
.register() | ||
|
||
mods.naturesaura.spawning.recipeBuilder() | ||
.input(item('minecraft:bone'), item('minecraft:dye:15') * 4) | ||
.entity(resource('minecraft:skeleton')) | ||
.aura(10) | ||
.time(10) | ||
.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
166 changes: 166 additions & 0 deletions
166
src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Altar.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,166 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.naturesaura; | ||
|
||
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 de.ellpeck.naturesaura.api.NaturesAuraAPI; | ||
import de.ellpeck.naturesaura.api.recipes.AltarRecipe; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Map; | ||
|
||
@RegistryDescription | ||
public class Altar extends VirtualizedRegistry<AltarRecipe> { | ||
|
||
public Altar() { | ||
super(Alias.generateOfClass(Altar.class).andGenerate("Infusion")); | ||
} | ||
|
||
@RecipeBuilderDescription(example = { | ||
@Example(".name('demo').input(item('minecraft:clay')).catalyst(item('minecraft:clay')).output(item('minecraft:diamond')).aura(100).time(100)"), | ||
@Example(".name(resource('example:demo')).input(item('minecraft:clay')).output(item('minecraft:gold_ingot') * 8).aura(30).time(5)"), | ||
@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).catalyst(item('minecraft:clay')).aura(50).time(100)") | ||
}) | ||
public RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
@Override | ||
public void onReload() { | ||
removeScripted().forEach(x -> NaturesAuraAPI.ALTAR_RECIPES.remove(x.name)); | ||
restoreFromBackup().forEach(x -> NaturesAuraAPI.ALTAR_RECIPES.put(x.name, x)); | ||
} | ||
|
||
public void add(AltarRecipe recipe) { | ||
if (recipe == null) return; | ||
addScripted(recipe); | ||
NaturesAuraAPI.ALTAR_RECIPES.put(recipe.name, recipe); | ||
} | ||
|
||
public boolean remove(AltarRecipe recipe) { | ||
if (recipe == null) return false; | ||
addBackup(recipe); | ||
return NaturesAuraAPI.ALTAR_RECIPES.remove(recipe.name) != null; | ||
} | ||
|
||
@MethodDescription(example = @Example("resource('naturesaura:infused_iron')")) | ||
public boolean removeByName(ResourceLocation name) { | ||
if (name == null) return false; | ||
var recipe = NaturesAuraAPI.ALTAR_RECIPES.remove(name); | ||
if (recipe == null) return false; | ||
addBackup(recipe); | ||
return true; | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('minecraft:rotten_flesh')")) | ||
public boolean removeByInput(IIngredient input) { | ||
return NaturesAuraAPI.ALTAR_RECIPES.entrySet().removeIf(r -> { | ||
for (var item : r.getValue().input.getMatchingStacks()) { | ||
if (input.test(item)) { | ||
addBackup(r.getValue()); | ||
return true; | ||
} | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeByCatalyst", example = @Example("item('naturesaura:crushing_catalyst')")) | ||
public boolean removeByCatalyst(IIngredient catalyst) { | ||
return NaturesAuraAPI.ALTAR_RECIPES.entrySet().removeIf(r -> { | ||
for (var item : r.getValue().catalyst.getMatchingStacks()) { | ||
if (catalyst.test(item)) { | ||
addBackup(r.getValue()); | ||
return true; | ||
} | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('minecraft:soul_sand')")) | ||
public boolean removeByOutput(IIngredient output) { | ||
return NaturesAuraAPI.ALTAR_RECIPES.entrySet().removeIf(r -> { | ||
if (output.test(r.getValue().output)) { | ||
addBackup(r.getValue()); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() { | ||
NaturesAuraAPI.ALTAR_RECIPES.values().forEach(this::addBackup); | ||
NaturesAuraAPI.ALTAR_RECIPES.entrySet().clear(); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<Map.Entry<ResourceLocation, AltarRecipe>> streamRecipes() { | ||
return new SimpleObjectStream<>(NaturesAuraAPI.ALTAR_RECIPES.entrySet()).setRemover(x -> remove(x.getValue())); | ||
} | ||
|
||
@Property(property = "input", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<AltarRecipe> { | ||
|
||
@Property(valid = @Comp(value = "null", type = Comp.Type.NOT), defaultValue = "IIngredient.EMPTY") | ||
private IIngredient catalyst = IIngredient.EMPTY; | ||
@Property(valid = @Comp(value = "1", type = Comp.Type.GTE)) | ||
private int aura; | ||
@Property(valid = @Comp(value = "1", type = Comp.Type.GTE)) | ||
private int time; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder catalyst(IIngredient catalyst) { | ||
this.catalyst = catalyst; | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder aura(int aura) { | ||
this.aura = aura; | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder time(int time) { | ||
this.time = time; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Nature's Aura Altar Recipe"; | ||
} | ||
|
||
public String getRecipeNamePrefix() { | ||
return "groovyscript_altar_"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateName(); | ||
validateItems(msg, 1, 1, 1, 1); | ||
validateFluids(msg); | ||
msg.add(catalyst == null, "catalyst must not be null"); | ||
msg.add(aura <= 0, "aura must be greater than or equal to 1, yet it was {}", aura); | ||
msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable AltarRecipe register() { | ||
if (!validate()) return null; | ||
AltarRecipe recipe = new AltarRecipe(name, input.get(0).toMcIngredient(), output.get(0), catalyst.toMcIngredient(), aura, time); | ||
ModSupport.NATURES_AURA.get().altar.add(recipe); | ||
return recipe; | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/NaturesAura.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,19 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.naturesaura; | ||
|
||
import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer; | ||
|
||
public class NaturesAura extends ModPropertyContainer { | ||
|
||
public final Altar altar = new Altar(); | ||
public final Ritual ritual = new Ritual(); | ||
public final Offering offering = new Offering(); | ||
public final Spawning spawning = new Spawning(); | ||
|
||
public NaturesAura() { | ||
addRegistry(altar); | ||
addRegistry(ritual); | ||
addRegistry(offering); | ||
addRegistry(spawning); | ||
} | ||
|
||
} |
Oops, something went wrong.