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
109b425
commit bc0e1c5
Showing
16 changed files
with
744 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,91 @@ | ||
|
||
// Auto generated groovyscript example file | ||
// MODS_LOADED: primal_tech | ||
|
||
println 'mod \'primal_tech\' detected, running script' | ||
|
||
// Clay Kiln: | ||
// Converts an input item into an output itemstack after a given amount of time. Requires the block below to be Minecraft | ||
// Fire or a Primal Tech Flame Grilled Wopper. Takes some time to heat up before beginning to smelt items. | ||
|
||
mods.primal_tech.clay_kiln.removeByInput(item('minecraft:gravel')) | ||
mods.primal_tech.clay_kiln.removeByOutput(item('primal_tech:charcoal_block')) | ||
// mods.primal_tech.clay_kiln.removeAll() | ||
|
||
mods.primal_tech.clay_kiln.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:clay')) | ||
.cookTime(50) | ||
.register() | ||
|
||
mods.primal_tech.clay_kiln.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:diamond') * 4) | ||
.cookTime(100) | ||
.register() | ||
|
||
|
||
|
||
// Stone Anvil: | ||
// Converts an input item into an output itemstack after being interacted with by a player using a Stone Mallet. | ||
|
||
// mods.primal_tech.stone_anvil.removeByInput(item('primal_tech:flint_block')) | ||
mods.primal_tech.stone_anvil.removeByOutput(item('minecraft:flint')) | ||
// mods.primal_tech.stone_anvil.removeAll() | ||
|
||
mods.primal_tech.stone_anvil.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:clay')) | ||
.register() | ||
|
||
mods.primal_tech.stone_anvil.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:diamond') * 4) | ||
.register() | ||
|
||
|
||
|
||
// Water Saw: | ||
// Converts an input item into an output itemstack after a given amount of time. Requires the block below it to be a water | ||
// source block, and the block below and behind it flowing water. | ||
|
||
mods.primal_tech.water_saw.removeByInput(item('minecraft:log')) | ||
mods.primal_tech.water_saw.removeByOutput(item('minecraft:planks:1')) | ||
// mods.primal_tech.water_saw.removeAll() | ||
|
||
mods.primal_tech.water_saw.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:clay')) | ||
.choppingTime(50) | ||
.register() | ||
|
||
mods.primal_tech.water_saw.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:diamond') * 4) | ||
.choppingTime(100) | ||
.register() | ||
|
||
|
||
|
||
// Wooden Basin: | ||
// Converts up to 4 items and 1000mb of fluid into an output itemstack. | ||
|
||
mods.primal_tech.wooden_basin.removeByInput(fluid('lava')) | ||
// mods.primal_tech.wooden_basin.removeByInput(item('minecraft:cobblestone')) | ||
// mods.primal_tech.wooden_basin.removeByOutput(item('minecraft:obsidian')) | ||
// mods.primal_tech.wooden_basin.removeAll() | ||
|
||
mods.primal_tech.wooden_basin.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.fluidInput(fluid('lava')) | ||
.output(item('minecraft:clay')) | ||
.register() | ||
|
||
mods.primal_tech.wooden_basin.recipeBuilder() | ||
.input(item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay')) | ||
.fluidInput(fluid('water')) | ||
.output(item('minecraft:diamond') * 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
126 changes: 126 additions & 0 deletions
126
src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/ClayKiln.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.primaltech; | ||
|
||
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.core.mixin.primal_tech.ClayKilnRecipesAccessor; | ||
import com.cleanroommc.groovyscript.helper.SimpleObjectStream; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import org.jetbrains.annotations.Nullable; | ||
import primal_tech.recipes.ClayKilnRecipes; | ||
|
||
@RegistryDescription | ||
public class ClayKiln extends VirtualizedRegistry<ClayKilnRecipes> { | ||
|
||
@RecipeBuilderDescription(example = { | ||
@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).cookTime(50)"), | ||
@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond') * 4).cookTime(100)") | ||
}) | ||
public static RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
@Override | ||
public void onReload() { | ||
ClayKilnRecipesAccessor.getRecipes().removeAll(removeScripted()); | ||
ClayKilnRecipesAccessor.getRecipes().addAll(restoreFromBackup()); | ||
} | ||
|
||
public void add(ClayKilnRecipes recipe) { | ||
if (recipe != null) { | ||
addScripted(recipe); | ||
ClayKilnRecipesAccessor.getRecipes().add(recipe); | ||
} | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.ADDITION) | ||
public ClayKilnRecipes add(ItemStack output, IIngredient input, int cookTime) { | ||
return recipeBuilder() | ||
.cookTime(cookTime) | ||
.input(input) | ||
.output(output) | ||
.register(); | ||
} | ||
|
||
public boolean remove(ClayKilnRecipes recipe) { | ||
if (ClayKilnRecipesAccessor.getRecipes().removeIf(r -> r == recipe)) { | ||
addBackup(recipe); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:gravel')")) | ||
public boolean removeByInput(IIngredient input) { | ||
return ClayKilnRecipesAccessor.getRecipes().removeIf(recipe -> { | ||
if (input.test(recipe.getInput())) { | ||
addBackup(recipe); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(example = @Example("item('primal_tech:charcoal_block')")) | ||
public boolean removeByOutput(IIngredient output) { | ||
return ClayKilnRecipesAccessor.getRecipes().removeIf(recipe -> { | ||
if (output.test(recipe.getOutput())) { | ||
addBackup(recipe); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<ClayKilnRecipes> streamRecipes() { | ||
return new SimpleObjectStream<>(ClayKilnRecipesAccessor.getRecipes()).setRemover(this::remove); | ||
} | ||
|
||
@MethodDescription(priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() { | ||
ClayKilnRecipesAccessor.getRecipes().forEach(this::addBackup); | ||
ClayKilnRecipesAccessor.getRecipes().clear(); | ||
} | ||
|
||
@Property(property = "input", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<ClayKilnRecipes> { | ||
|
||
@Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) | ||
private int cookTime; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder cookTime(int cookTime) { | ||
this.cookTime = cookTime; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Primal Tech Clay Kiln recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateItems(msg, 1, 1, 1, 1); | ||
validateFluids(msg); | ||
msg.add(cookTime < 0, "cookTime must be greater than or equal to 0, yet it was {}", cookTime); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable ClayKilnRecipes register() { | ||
if (!validate()) return null; | ||
ClayKilnRecipes recipe = null; | ||
for (ItemStack matchingStack : input.get(0).getMatchingStacks()) { | ||
recipe = ClayKilnRecipesAccessor.createClayKilnRecipes(output.get(0), matchingStack, cookTime); | ||
ModSupport.PRIMAL_TECH.get().clayKiln.add(recipe); | ||
} | ||
return recipe; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/PrimalTech.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,12 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.primaltech; | ||
|
||
import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; | ||
|
||
public class PrimalTech extends GroovyPropertyContainer { | ||
|
||
public final ClayKiln clayKiln = new ClayKiln(); | ||
public final StoneAnvil stoneAnvil = new StoneAnvil(); | ||
public final WaterSaw waterSaw = new WaterSaw(); | ||
public final WoodenBasin woodenBasin = new WoodenBasin(); | ||
|
||
} |
115 changes: 115 additions & 0 deletions
115
src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/StoneAnvil.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,115 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.primaltech; | ||
|
||
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.core.mixin.primal_tech.StoneAnvilRecipesAccessor; | ||
import com.cleanroommc.groovyscript.helper.SimpleObjectStream; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import org.jetbrains.annotations.Nullable; | ||
import primal_tech.recipes.StoneAnvilRecipes; | ||
|
||
@RegistryDescription | ||
public class StoneAnvil extends VirtualizedRegistry<StoneAnvilRecipes> { | ||
|
||
@RecipeBuilderDescription(example = { | ||
@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay'))"), | ||
@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond') * 4)") | ||
}) | ||
public static RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
@Override | ||
public void onReload() { | ||
StoneAnvilRecipesAccessor.getRecipes().removeAll(removeScripted()); | ||
StoneAnvilRecipesAccessor.getRecipes().addAll(restoreFromBackup()); | ||
} | ||
|
||
public void add(StoneAnvilRecipes recipe) { | ||
if (recipe != null) { | ||
addScripted(recipe); | ||
StoneAnvilRecipesAccessor.getRecipes().add(recipe); | ||
} | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.ADDITION) | ||
public StoneAnvilRecipes add(ItemStack output, IIngredient input) { | ||
return recipeBuilder() | ||
.input(input) | ||
.output(output) | ||
.register(); | ||
} | ||
|
||
public boolean remove(StoneAnvilRecipes recipe) { | ||
if (StoneAnvilRecipesAccessor.getRecipes().removeIf(r -> r == recipe)) { | ||
addBackup(recipe); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@MethodDescription(example = @Example(value = "item('primal_tech:flint_block')", commented = true)) | ||
public boolean removeByInput(IIngredient input) { | ||
return StoneAnvilRecipesAccessor.getRecipes().removeIf(recipe -> { | ||
if (input.test(recipe.getInput())) { | ||
addBackup(recipe); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:flint')")) | ||
public boolean removeByOutput(IIngredient output) { | ||
return StoneAnvilRecipesAccessor.getRecipes().removeIf(recipe -> { | ||
if (output.test(recipe.getOutput())) { | ||
addBackup(recipe); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<StoneAnvilRecipes> streamRecipes() { | ||
return new SimpleObjectStream<>(StoneAnvilRecipesAccessor.getRecipes()).setRemover(this::remove); | ||
} | ||
|
||
@MethodDescription(priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() { | ||
StoneAnvilRecipesAccessor.getRecipes().forEach(this::addBackup); | ||
StoneAnvilRecipesAccessor.getRecipes().clear(); | ||
} | ||
|
||
@Property(property = "input", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<StoneAnvilRecipes> { | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Primal Tech Stone Anvil recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateItems(msg, 1, 1, 1, 1); | ||
validateFluids(msg); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable StoneAnvilRecipes register() { | ||
if (!validate()) return null; | ||
StoneAnvilRecipes recipe = null; | ||
for (ItemStack matchingStack : input.get(0).getMatchingStacks()) { | ||
recipe = StoneAnvilRecipesAccessor.createStoneAnvilRecipes(output.get(0), matchingStack); | ||
ModSupport.PRIMAL_TECH.get().stoneAnvil.add(recipe); | ||
} | ||
return recipe; | ||
} | ||
} | ||
} |
Oops, something went wrong.