Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/postInit/betterwithaddons.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ mods.betterwithaddons.rotting.recipeBuilder()
.register()

mods.betterwithaddons.rotting.recipeBuilder()
.input(item('placeholdername:snack'))
.input(item('minecraft:apple'))
.time(100)
.key('groovy_example')
.rotted(item('minecraft:clay') * 4)
Expand Down
8 changes: 4 additions & 4 deletions examples/postInit/betterwithmods.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mods.betterwithmods.cauldron.removeByOutput(item('minecraft:gunpowder'))
// mods.betterwithmods.cauldron.removeAll()

mods.betterwithmods.cauldron.recipeBuilder()
.input(item('minecraft:clay'))
.input(item('minecraft:clay') * 3)
.output(item('minecraft:diamond'))
.heat(2)
.register()
Expand All @@ -62,7 +62,7 @@ mods.betterwithmods.crucible.removeByOutput(item('minecraft:gunpowder'))
// mods.betterwithmods.crucible.removeAll()

mods.betterwithmods.crucible.recipeBuilder()
.input(item('minecraft:clay'))
.input(item('minecraft:clay') * 3)
.output(item('minecraft:diamond'))
.heat(2)
.register()
Expand Down Expand Up @@ -98,7 +98,7 @@ mods.betterwithmods.hopper.recipeBuilder()

mods.betterwithmods.hopper.recipeBuilder()
.name('betterwithmods:wicker')
.input(item('minecraft:clay'))
.input(item('minecraft:clay') * 3)
.inWorldItemOutput(item('minecraft:gold_ingot'))
.register()

Expand Down Expand Up @@ -150,7 +150,7 @@ mods.betterwithmods.mill_stone.removeByOutput(item('minecraft:blaze_powder'))
// mods.betterwithmods.mill_stone.removeAll()

mods.betterwithmods.mill_stone.recipeBuilder()
.input(item('minecraft:diamond'))
.input(item('minecraft:diamond') * 3)
.output(item('minecraft:gold_ingot') * 16)
.register()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public boolean isEnabled() {

@RecipeBuilderDescription(example = {
@Example(".input(item('minecraft:gold_ingot'))"),
@Example(".input(item('placeholdername:snack')).time(100).key('groovy_example').rotted(item('minecraft:clay') * 4)")
@Example(".input(item('minecraft:apple')).time(100).key('groovy_example').rotted(item('minecraft:clay') * 4)")
})
public RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.cleanroommc.groovyscript.compat.mods.betterwithmods;

import betterwithmods.util.StackIngredient;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer;
import net.minecraft.item.crafting.Ingredient;

public class BetterWithMods extends GroovyPropertyContainer {

Expand All @@ -14,4 +17,17 @@ public class BetterWithMods extends GroovyPropertyContainer {
public final Heat heat = new Heat();
public final Hopper hopper = new Hopper();
public final HopperFilters hopperFilters = new HopperFilters();

public static class Helper {

/**
* Because Better With Mods checks if the ingredient is an instanceof {@link StackIngredient}
* to determine if the Ingredient has an amount, we have to use their custom Ingredient.
* <p>
* If this isn't used, then the recipe may appear correctly in JEI but will actually only consume 1 when done in-game.
*/
public static Ingredient fromIIngredient(IIngredient ingredient) {
return StackIngredient.fromIngredient(ingredient.getAmount(), ingredient.toMcIngredient());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class Cauldron extends StandardListRegistry<CookingPotRecipe> {

@RecipeBuilderDescription(example = {
@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"),
@Example(".input(item('minecraft:clay') * 3).output(item('minecraft:diamond')).heat(2)"),
@Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16).ignoreHeat()")
})
public RecipeBuilder recipeBuilder() {
Expand Down Expand Up @@ -110,7 +110,7 @@ public void validate(GroovyLog.Msg msg) {
public @Nullable CookingPotRecipe register() {
if (!validate()) return null;

CookingPotRecipe recipe = new CookingPotRecipe(input.stream().map(IIngredient::toMcIngredient).collect(Collectors.toList()), output, heat);
CookingPotRecipe recipe = new CookingPotRecipe(input.stream().map(BetterWithMods.Helper::fromIIngredient).collect(Collectors.toList()), output, heat);
recipe.setIgnoreHeat(ignoreHeat);
recipe.setPriority(priority);
ModSupport.BETTER_WITH_MODS.get().cauldron.add(recipe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class Crucible extends StandardListRegistry<CookingPotRecipe> {

@RecipeBuilderDescription(example = {
@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"),
@Example(".input(item('minecraft:clay') * 3).output(item('minecraft:diamond')).heat(2)"),
@Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16).ignoreHeat()")
})
public RecipeBuilder recipeBuilder() {
Expand Down Expand Up @@ -115,7 +115,7 @@ public void validate(GroovyLog.Msg msg) {
public @Nullable CookingPotRecipe register() {
if (!validate()) return null;

CookingPotRecipe recipe = new CookingPotRecipe(input.stream().map(IIngredient::toMcIngredient).collect(Collectors.toList()), output, heat);
CookingPotRecipe recipe = new CookingPotRecipe(input.stream().map(BetterWithMods.Helper::fromIIngredient).collect(Collectors.toList()), output, heat);
recipe.setIgnoreHeat(ignoreHeat);
recipe.setPriority(priority);
ModSupport.BETTER_WITH_MODS.get().crucible.add(recipe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Hopper extends StandardListRegistry<HopperInteractions.HopperRecipe

@RecipeBuilderDescription(example = {
@Example(".name('betterwithmods:iron_bar').input(ore('sand')).output(item('minecraft:clay')).inWorldItemOutput(item('minecraft:gold_ingot'))"),
@Example(".name('betterwithmods:wicker').input(item('minecraft:clay')).inWorldItemOutput(item('minecraft:gold_ingot'))")
@Example(".name('betterwithmods:wicker').input(item('minecraft:clay') * 3).inWorldItemOutput(item('minecraft:gold_ingot'))")
})
public RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
Expand Down Expand Up @@ -103,7 +103,7 @@ public void validate(GroovyLog.Msg msg) {
public @Nullable HopperInteractions.HopperRecipe register() {
if (!validate()) return null;

HopperInteractions.HopperRecipe recipe = new HopperInteractions.HopperRecipe(super.name.toString(), input.get(0).toMcIngredient(), output, inWorldItemOutput);
HopperInteractions.HopperRecipe recipe = new HopperInteractions.HopperRecipe(super.name.toString(), BetterWithMods.Helper.fromIIngredient(input.get(0)), output, inWorldItemOutput);
ModSupport.BETTER_WITH_MODS.get().hopper.add(recipe);
return recipe;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Collection<MillRecipe> getRecipes() {
}

@RecipeBuilderDescription(example = {
@Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16)"),
@Example(".input(item('minecraft:diamond') * 3).output(item('minecraft:gold_ingot') * 16)"),
@Example(".input(item('minecraft:diamond_block')).output(item('minecraft:gold_ingot'), item('minecraft:gold_block'), item('minecraft:clay'))")
})
public RecipeBuilder recipeBuilder() {
Expand Down Expand Up @@ -105,11 +105,6 @@ public String getErrorMsg() {
return "Error adding Better With Mods Mill recipe";
}

@Override
protected int getMaxItemInput() {
return 1;
}

@Override
public void validate(GroovyLog.Msg msg) {
validateItems(msg, 1, 3, 1, 3);
Expand All @@ -122,7 +117,7 @@ public void validate(GroovyLog.Msg msg) {
public @Nullable MillRecipe register() {
if (!validate()) return null;

MillRecipe recipe = new MillRecipe(input.stream().map(IIngredient::toMcIngredient).collect(Collectors.toList()), output);
MillRecipe recipe = new MillRecipe(input.stream().map(BetterWithMods.Helper::fromIIngredient).collect(Collectors.toList()), output);
recipe.setSound(soundEvent);
recipe.setTicks(ticks);
recipe.setPriority(priority);
Expand Down