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 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
- Loading branch information
1 parent
6bd82e7
commit 81fd37e
Showing
8 changed files
with
266 additions
and
0 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,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() | ||
|
||
|
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
106 changes: 106 additions & 0 deletions
106
src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/MoonlightForge.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,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<MoonlightForgeRecipe> { | ||
|
||
@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<MoonlightForgeRecipe> 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<MoonlightForgeRecipe> { | ||
|
||
@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; | ||
} | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/Scrapper.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,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<ScrapperRecipe> { | ||
|
||
@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<ScrapperRecipe> 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<ScrapperRecipe> { | ||
|
||
@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; | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/TheAurorian.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,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(); | ||
|
||
} |
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