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.
Co-authored-by: brachy84 <[email protected]>
- Loading branch information
1 parent
a6fd8d9
commit fc8ae84
Showing
7 changed files
with
171 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,27 @@ | ||
|
||
// Auto generated groovyscript example file | ||
// MODS_LOADED: botanicadds | ||
|
||
println 'mod \'botanicadds\' detected, running script' | ||
|
||
// Gaia Plate: | ||
// Converts an number of input items into an output itemstack, consuming a given amount of mana when dropped in-world atop | ||
// a Gaia Agglomeration Plate as part of a multiblock structure. | ||
|
||
mods.botanicadds.gaia_plate.removeByInput(item('botania:manaresource')) | ||
mods.botanicadds.gaia_plate.removeByOutput(item('botanicadds:gaiasteel_ingot')) | ||
// mods.botanicadds.gaia_plate.removeAll() | ||
|
||
mods.botanicadds.gaia_plate.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:gold_ingot') * 16) | ||
.mana(1000) | ||
.register() | ||
|
||
mods.botanicadds.gaia_plate.recipeBuilder() | ||
.input(item('minecraft:diamond_block'), item('minecraft:gold_block'), item('minecraft:clay')) | ||
.output(item('minecraft:gold_ingot')) | ||
.mana(100) | ||
.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
9 changes: 9 additions & 0 deletions
9
...main/java/com/cleanroommc/groovyscript/compat/mods/botanicadditions/BotanicAdditions.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,9 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.botanicadditions; | ||
|
||
import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; | ||
|
||
public class BotanicAdditions extends GroovyPropertyContainer { | ||
|
||
public final GaiaPlate gaiaPlate = new GaiaPlate(); | ||
|
||
} |
122 changes: 122 additions & 0 deletions
122
src/main/java/com/cleanroommc/groovyscript/compat/mods/botanicadditions/GaiaPlate.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,122 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.botanicadditions; | ||
|
||
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.ingredient.OreDictIngredient; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.oredict.OreDictionary; | ||
import org.jetbrains.annotations.Nullable; | ||
import tk.zeitheron.botanicadds.api.GaiaPlateRecipes; | ||
|
||
@RegistryDescription | ||
public class GaiaPlate extends VirtualizedRegistry<GaiaPlateRecipes.RecipeGaiaPlate> { | ||
|
||
@RecipeBuilderDescription(example = { | ||
@Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16).mana(1000)"), | ||
@Example(".input(item('minecraft:diamond_block'), item('minecraft:gold_block'), item('minecraft:clay')).output(item('minecraft:gold_ingot')).mana(100)") | ||
}) | ||
public RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
@Override | ||
public void onReload() { | ||
GaiaPlateRecipes.gaiaRecipes.removeAll(removeScripted()); | ||
GaiaPlateRecipes.gaiaRecipes.addAll(restoreFromBackup()); | ||
} | ||
|
||
public void add(GaiaPlateRecipes.RecipeGaiaPlate recipe) { | ||
if (recipe != null) { | ||
addScripted(recipe); | ||
GaiaPlateRecipes.gaiaRecipes.add(recipe); | ||
} | ||
} | ||
|
||
public boolean remove(GaiaPlateRecipes.RecipeGaiaPlate recipe) { | ||
if (GaiaPlateRecipes.gaiaRecipes.removeIf(r -> r == recipe)) { | ||
addBackup(recipe); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@MethodDescription(example = @Example("item('botanicadds:gaiasteel_ingot')")) | ||
public boolean removeByOutput(IIngredient output) { | ||
return GaiaPlateRecipes.gaiaRecipes.removeIf(r -> { | ||
if (output.test(r.getOutput())) { | ||
addBackup(r); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(example = @Example("item('botania:manaresource')")) | ||
public boolean removeByInput(IIngredient input) { | ||
return GaiaPlateRecipes.gaiaRecipes.removeIf(r -> { | ||
for (Object ingredient : r.getInputs()) { | ||
if ((ingredient instanceof String s && (input instanceof OreDictIngredient ore && ore.getOreDict().equals(s) || OreDictionary.getOres(s, false).stream().anyMatch(input))) || | ||
(ingredient instanceof ItemStack is && input.test(is))) { | ||
addBackup(r); | ||
return true; | ||
} | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<GaiaPlateRecipes.RecipeGaiaPlate> streamRecipes() { | ||
return new SimpleObjectStream<>(GaiaPlateRecipes.gaiaRecipes).setRemover(this::remove); | ||
} | ||
|
||
@MethodDescription(priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() { | ||
GaiaPlateRecipes.gaiaRecipes.forEach(this::addBackup); | ||
GaiaPlateRecipes.gaiaRecipes.clear(); | ||
} | ||
|
||
@Property(property = "input", valid = @Comp("1")) | ||
@Property(property = "output", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<GaiaPlateRecipes.RecipeGaiaPlate> { | ||
|
||
@Property(defaultValue = "1", valid = @Comp(value = "1", type = Comp.Type.GTE)) | ||
private int mana = 1; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder mana(int mana) { | ||
this.mana = mana; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Botanic Additions Gaia Plate recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateItems(msg, 1, Integer.MAX_VALUE, 1, 1); | ||
validateFluids(msg); | ||
msg.add(mana <= 0, "mana must be a positive integer greater than 0, yet it was {}", mana); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable GaiaPlateRecipes.RecipeGaiaPlate register() { | ||
if (!validate()) return null; | ||
Object[] inputs = input.stream() | ||
.map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]) | ||
.toArray(); | ||
GaiaPlateRecipes.RecipeGaiaPlate recipe = new GaiaPlateRecipes.RecipeGaiaPlate(output.get(0), mana, inputs); | ||
ModSupport.BOTANIC_ADDITIONS.get().gaiaPlate.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