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.
* skip documenting bridge methods * Horse Power compat
- Loading branch information
1 parent
68ef30d
commit 73e8d24
Showing
12 changed files
with
817 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,133 @@ | ||
|
||
// Auto generated groovyscript example file | ||
// MODS_LOADED: horsepower | ||
|
||
log.info 'mod \'horsepower\' detected, running script' | ||
|
||
// Horse Chopping Block: | ||
// Converts an itemstack input into an itemstack output, with the chance of an additional output after a configurable | ||
// amount of processing has been done. Depending on if the config option `Separate Chopping Recipes` is true, this may | ||
// affect both Horse and Hand Chopping Blocks. Only the Horse Chopping Block can produce secondary outputs. | ||
|
||
mods.horsepower.chopping_block.removeByInput(item('minecraft:log:3')) | ||
mods.horsepower.chopping_block.removeByOutput(item('minecraft:planks:4')) | ||
// mods.horsepower.chopping_block.removeAll() | ||
|
||
mods.horsepower.chopping_block.recipeBuilder() | ||
.input(item('minecraft:clay')) | ||
.output(item('minecraft:diamond') * 5) | ||
.time(5) | ||
.register() | ||
|
||
mods.horsepower.chopping_block.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:gold_ingot')) | ||
.time(1) | ||
.register() | ||
|
||
mods.horsepower.chopping_block.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:clay'), item('minecraft:diamond')) | ||
.chance(50) | ||
.time(2) | ||
.register() | ||
|
||
|
||
// Horse Grindstone: | ||
// Converts an itemstack input into an itemstack output, with the chance of an additional output after a configurable | ||
// amount of processing has been done. Depending on if the config option `Separate Grindstone Recipes` is true, this may | ||
// affect both Horse and Hand Grindstones. | ||
|
||
mods.horsepower.grindstone.removeByInput(item('minecraft:double_plant:4')) | ||
mods.horsepower.grindstone.removeByOutput(item('minecraft:sugar')) | ||
// mods.horsepower.grindstone.removeAll() | ||
|
||
mods.horsepower.grindstone.recipeBuilder() | ||
.input(item('minecraft:clay')) | ||
.output(item('minecraft:diamond') * 5) | ||
.time(5) | ||
.register() | ||
|
||
mods.horsepower.grindstone.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:gold_ingot')) | ||
.time(1) | ||
.register() | ||
|
||
mods.horsepower.grindstone.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:clay'), item('minecraft:diamond')) | ||
.chance(50) | ||
.time(2) | ||
.register() | ||
|
||
|
||
// Manual Chopping Block: | ||
// Converts an itemstack input into an itemstack output after a configurable amount of processing has been done. Depending | ||
// on if the config option `Separate Chopping Recipes` is true, this may affect both Horse and Hand Chopping Blocks. | ||
|
||
mods.horsepower.manual_chopping_block.removeByInput(item('minecraft:log:3')) | ||
mods.horsepower.manual_chopping_block.removeByOutput(item('minecraft:planks:4')) | ||
// mods.horsepower.manual_chopping_block.removeAll() | ||
|
||
mods.horsepower.manual_chopping_block.recipeBuilder() | ||
.input(item('minecraft:clay')) | ||
.output(item('minecraft:diamond') * 5) | ||
.time(5) | ||
.register() | ||
|
||
mods.horsepower.manual_chopping_block.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:gold_ingot')) | ||
.time(1) | ||
.register() | ||
|
||
|
||
// Manual Grindstone: | ||
// Converts an itemstack input into an itemstack output, with the chance of an additional output after a configurable | ||
// amount of processing has been done. Depending on if the config option `Separate Grindstone Recipes` is true, this may | ||
// affect both Horse and Hand Grindstones. | ||
|
||
mods.horsepower.manual_grindstone.removeByInput(item('minecraft:double_plant:4')) | ||
mods.horsepower.manual_grindstone.removeByOutput(item('minecraft:sugar')) | ||
// mods.horsepower.manual_grindstone.removeAll() | ||
|
||
mods.horsepower.manual_grindstone.recipeBuilder() | ||
.input(item('minecraft:clay')) | ||
.output(item('minecraft:diamond') * 5) | ||
.time(5) | ||
.register() | ||
|
||
mods.horsepower.manual_grindstone.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:gold_ingot')) | ||
.time(1) | ||
.register() | ||
|
||
mods.horsepower.manual_grindstone.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:clay'), item('minecraft:diamond')) | ||
.chance(50) | ||
.time(2) | ||
.register() | ||
|
||
|
||
// Horse Press: | ||
// Converts an itemstack into another itemstack or a fluidstack by a horse running laps. | ||
|
||
mods.horsepower.press.removeByInput(item('minecraft:wheat_seeds')) | ||
mods.horsepower.press.removeByOutput(fluid('water')) | ||
// mods.horsepower.press.removeByOutput(item('minecraft:dirt')) | ||
// mods.horsepower.press.removeAll() | ||
|
||
mods.horsepower.press.recipeBuilder() | ||
.input(item('minecraft:clay')) | ||
.output(item('minecraft:diamond') * 5) | ||
.register() | ||
|
||
mods.horsepower.press.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.fluidOutput(fluid('lava') * 500) | ||
.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
133 changes: 133 additions & 0 deletions
133
src/main/java/com/cleanroommc/groovyscript/compat/mods/horsepower/ChoppingBlock.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,133 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.horsepower; | ||
|
||
import com.cleanroommc.groovyscript.api.GroovyBlacklist; | ||
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.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.StandardListRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.Nullable; | ||
import se.gory_moon.horsepower.recipes.ChoppingBlockRecipe; | ||
import se.gory_moon.horsepower.recipes.HPRecipes; | ||
|
||
import java.util.Collection; | ||
|
||
@RegistryDescription | ||
public class ChoppingBlock extends StandardListRegistry<ChoppingBlockRecipe> { | ||
|
||
@RecipeBuilderDescription(example = { | ||
@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 5).time(5)"), | ||
@Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot')).time(1)"), | ||
@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay'), item('minecraft:diamond')).chance(50).time(2)") | ||
}) | ||
public static RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
// have to override onReload and add to add recipes to the registry due to the actual setup being a map | ||
@Override | ||
public Collection<ChoppingBlockRecipe> getRecipes() { | ||
return HPRecipes.instance().getChoppingRecipes(); | ||
} | ||
|
||
@Override | ||
@GroovyBlacklist | ||
@ApiStatus.Internal | ||
public void onReload() { | ||
var recipes = getRecipes(); | ||
recipes.removeAll(removeScripted()); | ||
for (var recipe : restoreFromBackup()) { | ||
HPRecipes.instance().addChoppingRecipe(recipe, false); | ||
} | ||
} | ||
|
||
@Override | ||
@MethodDescription(type = MethodDescription.Type.ADDITION, description = "groovyscript.wiki.add_to_list", priority = 500) | ||
public boolean add(ChoppingBlockRecipe recipe) { | ||
HPRecipes.instance().addChoppingRecipe(recipe, false); | ||
return recipe != null && doAddScripted(recipe); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.horsepower.chopping_block.add0", type = MethodDescription.Type.ADDITION) | ||
public ChoppingBlockRecipe add(IIngredient input, ItemStack output, int time) { | ||
return recipeBuilder() | ||
.time(time) | ||
.output(output) | ||
.input(input) | ||
.register(); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.horsepower.chopping_block.add1", type = MethodDescription.Type.ADDITION) | ||
public ChoppingBlockRecipe add(IIngredient input, ItemStack output, ItemStack secondary, int chance, int time) { | ||
return recipeBuilder() | ||
.time(time) | ||
.chance(chance) | ||
.output(output, secondary) | ||
.input(input) | ||
.register(); | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:log:3')")) | ||
public boolean removeByInput(IIngredient input) { | ||
return getRecipes().removeIf(entry -> input.test(entry.getInput()) && doAddBackup(entry)); | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:planks:4')")) | ||
public boolean removeByOutput(IIngredient output) { | ||
return getRecipes().removeIf(entry -> (output.test(entry.getOutput()) || output.test(entry.getSecondary())) && doAddBackup(entry)); | ||
} | ||
|
||
@Property(property = "input", comp = @Comp(eq = 1)) | ||
@Property(property = "output", comp = @Comp(gte = 1, lte = 2)) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<ChoppingBlockRecipe> { | ||
|
||
@Property(comp = @Comp(gte = 0, lte = 100)) | ||
private int chance; | ||
@Property(comp = @Comp(gt = 0)) | ||
private int time; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder chance(int chance) { | ||
this.chance = chance; | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder time(int time) { | ||
this.time = time; | ||
return this; | ||
} | ||
|
||
// todo this can only handle an input with a size of 1, should validate that here | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Horse Power Chopping Block recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateItems(msg, 1, 1, 1, 2); | ||
validateFluids(msg); | ||
msg.add(chance < 0 || chance > 100, "chance must be a non negative integer less than 100, yet it was {}", chance); | ||
msg.add(time <= 0, "time must be greater than 0, yet it was {}", time); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable ChoppingBlockRecipe register() { | ||
if (!validate()) return null; | ||
ChoppingBlockRecipe recipe = null; | ||
for (var stack : input.get(0).getMatchingStacks()) { | ||
recipe = new ChoppingBlockRecipe(stack, output.get(0), output.getOrEmpty(1), chance, time); | ||
ModSupport.HORSE_POWER.get().choppingBlock.add(recipe); | ||
} | ||
return recipe; | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.