generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Atum 2 compat * V after T --------- Co-authored-by: brachy84 <[email protected]>
- Loading branch information
1 parent
bbeaefd
commit 4a76dd4
Showing
9 changed files
with
432 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,69 @@ | ||
|
||
// Auto generated groovyscript example file | ||
// MODS_LOADED: atum | ||
|
||
println 'mod \'atum\' detected, running script' | ||
|
||
// Kiln: | ||
// Smelts an input item into an output itemstack and giving experience similar to a Furnace, but can process up to 4 stacks | ||
// simultaneously. Makes a copy of the vanilla furnace recipes, excluding entries on a blacklist. | ||
|
||
mods.atum.kiln.removeByInput(item('minecraft:netherrack')) | ||
mods.atum.kiln.removeByOutput(item('minecraft:stone')) | ||
// mods.atum.kiln.removeAll() | ||
|
||
mods.atum.kiln.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:clay')) | ||
.register() | ||
|
||
mods.atum.kiln.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:clay') * 4) | ||
.experience(0.5f) | ||
.register() | ||
|
||
|
||
// Quern: | ||
// Converts an input item into an output itemstack after a given number of rotations, which are done via a player right | ||
// clicking the Quern. | ||
|
||
mods.atum.quern.removeByInput(item('minecraft:blaze_rod')) | ||
mods.atum.quern.removeByOutput(item('minecraft:sugar')) | ||
// mods.atum.quern.removeAll() | ||
|
||
mods.atum.quern.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:clay')) | ||
.rotations(1) | ||
.register() | ||
|
||
mods.atum.quern.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:clay') * 4) | ||
.rotations(5) | ||
.register() | ||
|
||
|
||
// Spinning Wheel: | ||
// Converts three input items into an output itemstack after a given number of rotations for each input item, items are | ||
// inserted by interacting with the top, rotations are increased by interacting with the top, and output items are | ||
// extracted by interacting with the spool side. | ||
|
||
mods.atum.spinning_wheel.removeByInput(item('atum:flax')) | ||
mods.atum.spinning_wheel.removeByOutput(item('minecraft:string')) | ||
// mods.atum.spinning_wheel.removeAll() | ||
|
||
mods.atum.spinning_wheel.recipeBuilder() | ||
.input(item('minecraft:diamond')) | ||
.output(item('minecraft:clay')) | ||
.rotations(1) | ||
.register() | ||
|
||
mods.atum.spinning_wheel.recipeBuilder() | ||
.input(item('minecraft:gold_ingot')) | ||
.output(item('minecraft:clay') * 4) | ||
.rotations(5) | ||
.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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/cleanroommc/groovyscript/compat/mods/atum/Atum.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,11 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.atum; | ||
|
||
import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; | ||
|
||
public class Atum extends GroovyPropertyContainer { | ||
|
||
public final Kiln kiln = new Kiln(); | ||
public final Quern quern = new Quern(); | ||
public final SpinningWheel spinningWheel = new SpinningWheel(); | ||
|
||
} |
111 changes: 111 additions & 0 deletions
111
src/main/java/com/cleanroommc/groovyscript/compat/mods/atum/Kiln.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,111 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.atum; | ||
|
||
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.ingredient.OreDictIngredient; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; | ||
import com.teammetallurgy.atum.api.recipe.RecipeHandlers; | ||
import com.teammetallurgy.atum.api.recipe.kiln.IKilnRecipe; | ||
import com.teammetallurgy.atum.api.recipe.kiln.KilnRecipe; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@RegistryDescription | ||
public class Kiln extends ForgeRegistryWrapper<IKilnRecipe> { | ||
|
||
public Kiln() { | ||
super(RecipeHandlers.kilnRecipes); | ||
} | ||
|
||
@RecipeBuilderDescription(example = { | ||
@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay'))"), | ||
@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay') * 4).experience(0.5f)") | ||
}) | ||
public RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
public IKilnRecipe add(IIngredient input, ItemStack output) { | ||
return add(input, output, 0); | ||
} | ||
|
||
public IKilnRecipe add(IIngredient input, ItemStack output, float experience) { | ||
return recipeBuilder() | ||
.experience(experience) | ||
.input(input) | ||
.output(output) | ||
.register(); | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:netherrack')")) | ||
public void removeByInput(IIngredient input) { | ||
for (IKilnRecipe recipe : getRegistry()) { | ||
if (recipe.getInput().stream().anyMatch(input)) { | ||
remove(recipe); | ||
} | ||
} | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:stone')")) | ||
public void removeByOutput(IIngredient output) { | ||
for (IKilnRecipe recipe : getRegistry()) { | ||
if (output.test(recipe.getOutput())) { | ||
remove(recipe); | ||
} | ||
} | ||
} | ||
|
||
@Property(property = "name") | ||
@Property(property = "input", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<IKilnRecipe> { | ||
|
||
@Property(valid = @Comp(type = Comp.Type.GTE, value = "0")) | ||
private float experience; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder experience(float experience) { | ||
this.experience = experience; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Atum 2 Kiln recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateName(); | ||
validateItems(msg, 1, 1, 1, 1); | ||
validateFluids(msg); | ||
msg.add(experience < 0, "experience must be a non negative float, yet it was {}", experience); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable IKilnRecipe register() { | ||
if (!validate()) return null; | ||
IKilnRecipe recipe = null; | ||
if (input.get(0) instanceof OreDictIngredient oreDictIngredient) { | ||
recipe = new KilnRecipe(oreDictIngredient.getOreDict(), output.get(0), experience); | ||
recipe.setRegistryName(super.name); | ||
ModSupport.ATUM.get().kiln.add(recipe); | ||
return recipe; | ||
} else { | ||
ItemStack[] matchingStacks = input.get(0).getMatchingStacks(); | ||
for (int i = 0; i < matchingStacks.length; i++) { | ||
recipe = new KilnRecipe(matchingStacks[i], output.get(0), experience); | ||
var location = new ResourceLocation(super.name.getNamespace(), super.name.getPath() + i); | ||
recipe.setRegistryName(location); | ||
ModSupport.ATUM.get().kiln.add(recipe); | ||
} | ||
} | ||
return recipe; | ||
} | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
src/main/java/com/cleanroommc/groovyscript/compat/mods/atum/Quern.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,111 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.atum; | ||
|
||
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.ingredient.OreDictIngredient; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; | ||
import com.teammetallurgy.atum.api.recipe.RecipeHandlers; | ||
import com.teammetallurgy.atum.api.recipe.quern.IQuernRecipe; | ||
import com.teammetallurgy.atum.api.recipe.quern.QuernRecipe; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@RegistryDescription | ||
public class Quern extends ForgeRegistryWrapper<IQuernRecipe> { | ||
|
||
public Quern() { | ||
super(RecipeHandlers.quernRecipes); | ||
} | ||
|
||
@RecipeBuilderDescription(example = { | ||
@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).rotations(1)"), | ||
@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay') * 4).rotations(5)") | ||
}) | ||
public RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
public IQuernRecipe add(IIngredient input, ItemStack output) { | ||
return add(input, output, 1); | ||
} | ||
|
||
public IQuernRecipe add(IIngredient input, ItemStack output, int rotations) { | ||
return recipeBuilder() | ||
.rotations(rotations) | ||
.input(input) | ||
.output(output) | ||
.register(); | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:blaze_rod')")) | ||
public void removeByInput(IIngredient input) { | ||
for (IQuernRecipe recipe : getRegistry()) { | ||
if (recipe.getInput().stream().anyMatch(input)) { | ||
remove(recipe); | ||
} | ||
} | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:sugar')")) | ||
public void removeByOutput(IIngredient output) { | ||
for (IQuernRecipe recipe : getRegistry()) { | ||
if (output.test(recipe.getOutput())) { | ||
remove(recipe); | ||
} | ||
} | ||
} | ||
|
||
@Property(property = "name") | ||
@Property(property = "input", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public static class RecipeBuilder extends AbstractRecipeBuilder<IQuernRecipe> { | ||
|
||
@Property(valid = @Comp(type = Comp.Type.GT, value = "0")) | ||
private int rotations; | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder rotations(int rotations) { | ||
this.rotations = rotations; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Atum 2 Quern recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateName(); | ||
validateItems(msg, 1, 1, 1, 1); | ||
validateFluids(msg); | ||
msg.add(rotations <= 0, "rotations must be a greater than 0, yet it was {}", rotations); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable IQuernRecipe register() { | ||
if (!validate()) return null; | ||
IQuernRecipe recipe = null; | ||
if (input.get(0) instanceof OreDictIngredient oreDictIngredient) { | ||
recipe = new QuernRecipe(oreDictIngredient.getOreDict(), output.get(0), rotations); | ||
recipe.setRegistryName(super.name); | ||
ModSupport.ATUM.get().quern.add(recipe); | ||
return recipe; | ||
} else { | ||
ItemStack[] matchingStacks = input.get(0).getMatchingStacks(); | ||
for (int i = 0; i < matchingStacks.length; i++) { | ||
recipe = new QuernRecipe(matchingStacks[i], output.get(0), rotations); | ||
var location = new ResourceLocation(super.name.getNamespace(), super.name.getPath() + i); | ||
recipe.setRegistryName(location); | ||
ModSupport.ATUM.get().quern.add(recipe); | ||
} | ||
} | ||
return recipe; | ||
} | ||
} | ||
} |
Oops, something went wrong.