Skip to content

Commit

Permalink
fix mod compat
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 committed Oct 6, 2024
1 parent 026502e commit 883efac
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ public Collection<AgglomerationRecipe> getRecipes() {

@MethodDescription(example = @Example("item('botania:manaresource:4')"))
public boolean removeByOutput(IIngredient output) {
return getRecipes().removeIf(r -> output.test(r.getRecipeOutputCopy()) && addBackup(r));
return getRecipes().removeIf(r -> output.test(r.getRecipeOutputCopy()) && doAddBackup(r));
}

@MethodDescription(example = @Example(value = "item('botania:manaresource:2')", commented = true))
public boolean removeByInput(IIngredient input) {
return getRecipes().removeIf(r -> {
for (var stack : r.getRecipeStacks()) {
if (input.test(stack)) {
return addBackup(r);
return doAddBackup(r);
}
}
for (var string : r.getRecipeOreKeys()) {
if (input instanceof OreDictIngredient ore && ore.getOreDict().equals(string)) {
return addBackup(r);
return doAddBackup(r);
}
}
return false;
Expand All @@ -61,17 +61,17 @@ public boolean removeByInput(IIngredient input) {

@MethodDescription(example = @Example(value = "blockstate('botania:livingrock')", commented = true))
public boolean removeByCenter(IBlockState center) {
return getRecipes().removeIf(x -> x.multiblockCenter == center && addBackup(x));
return getRecipes().removeIf(x -> x.multiblockCenter == center && doAddBackup(x));
}

@MethodDescription(example = @Example(value = "blockstate('minecraft:lapis_block')", commented = true))
public boolean removeByEdge(IBlockState edge) {
return getRecipes().removeIf(x -> x.multiblockEdge == edge && addBackup(x));
return getRecipes().removeIf(x -> x.multiblockEdge == edge && doAddBackup(x));
}

@MethodDescription(example = @Example(value = "blockstate('botania:livingrock')", commented = true))
public boolean removeByCorner(IBlockState corner) {
return getRecipes().removeIf(x -> x.multiblockCorner == corner && addBackup(x));
return getRecipes().removeIf(x -> x.multiblockCorner == corner && doAddBackup(x));
}

@Property(property = "input", comp = @Comp(gte = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public RecipeBuilder recipeBuilder() {

@MethodDescription(example = @Example("item('minecraft:gold_ore')"))
public void removeByInput(IIngredient input) {
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && addBackup(r));
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && doAddBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:iron_ingot')"))
public void removeByOutput(IIngredient output) {
getRecipes().removeIf(r -> output.test(r.getOutput()) && addBackup(r));
getRecipes().removeIf(r -> output.test(r.getOutput()) && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public RecipeBuilder recipeBuilder() {

@MethodDescription(example = @Example("item('minecraft:fish')"))
public void removeByInput(IIngredient input) {
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && addBackup(r));
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && doAddBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:cooked_mutton')"))
public void removeByOutput(IIngredient output) {
getRecipes().removeIf(r -> output.test(r.getOutput()) && addBackup(r));
getRecipes().removeIf(r -> output.test(r.getOutput()) && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public RecipeBuilder recipeBuilder() {
@Example("item('minecraft:diamond_hoe')"), @Example(value = "item('futuremc:netherite_ingot')", commented = true),
})
public void removeByInput(IIngredient input) {
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && addBackup(r));
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && doAddBackup(r));
}

@MethodDescription(example = @Example("item('futuremc:netherite_pickaxe')"))
public void removeByOutput(IIngredient output) {
getRecipes().removeIf(r -> output.test(r.getOutput()) && addBackup(r));
getRecipes().removeIf(r -> output.test(r.getOutput()) && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public RecipeBuilder recipeBuilder() {

@MethodDescription(example = @Example("item('minecraft:porkchop')"))
public void removeByInput(IIngredient input) {
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && addBackup(r));
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && doAddBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:baked_potato')"))
public void removeByOutput(IIngredient output) {
getRecipes().removeIf(r -> output.test(r.getOutput()) && addBackup(r));
getRecipes().removeIf(r -> output.test(r.getOutput()) && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public RecipeBuilder recipeBuilder() {

@MethodDescription(example = @Example("item('minecraft:stonebrick')"))
public void removeByInput(IIngredient input) {
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && addBackup(r));
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && doAddBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:stone_slab')"))
public void removeByOutput(IIngredient output) {
getRecipes().removeIf(r -> output.test(r.getOutput()) && addBackup(r));
getRecipes().removeIf(r -> output.test(r.getOutput()) && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public Collection<ICrushingTableRecipe> getRecipes() {

@MethodDescription(example = @Example("item('minecraft:iron_ore')"))
public boolean removeByInput(IIngredient input) {
return getRecipes().removeIf(r -> input.test(r.getInput()) && addBackup(r));
return getRecipes().removeIf(r -> input.test(r.getInput()) && doAddBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:gunpowder')"))
public boolean removeByOutput(IIngredient output) {
return getRecipes().removeIf(r -> output.test(r.getOutput()) && addBackup(r));
return getRecipes().removeIf(r -> output.test(r.getOutput()) && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public Collection<IGasificationUnitRecipe> getRecipes() {

@MethodDescription
public boolean removeByInput(IIngredient input) {
return getRecipes().removeIf(r -> input.test(r.getInput()) && addBackup(r));
return getRecipes().removeIf(r -> input.test(r.getInput()) && doAddBackup(r));
}

@MethodDescription
public boolean removeByOutput(IIngredient output) {
return getRecipes().removeIf(r -> (output.test(r.getItemOutput()) || output.test(r.getFluidOutput())) && addBackup(r));
return getRecipes().removeIf(r -> (output.test(r.getItemOutput()) || output.test(r.getFluidOutput())) && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public Collection<IGrinderRecipe> getRecipes() {

@MethodDescription(example = @Example("item('minecraft:iron_ore')"))
public boolean removeByInput(IIngredient input) {
return getRecipes().removeIf(r -> input.test(r.getInput()) && addBackup(r));
return getRecipes().removeIf(r -> input.test(r.getInput()) && doAddBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:gravel')"))
public boolean removeByOutput(IIngredient output) {
return getRecipes().removeIf(r -> (output.test(r.getPrimaryOutput()) || output.test(r.getSecondaryOutput())) && addBackup(r));
return getRecipes().removeIf(r -> (output.test(r.getPrimaryOutput()) || output.test(r.getSecondaryOutput())) && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ public Collection<IHydraulicPressRecipe> getRecipes() {

@MethodDescription(example = @Example("item('minecraft:iron_ingot')"))
public boolean removeByInput(IIngredient input) {
return getRecipes().removeIf(r -> input.test(r.getInput()) && addBackup(r));
return getRecipes().removeIf(r -> input.test(r.getInput()) && doAddBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:cobblestone')"))
public boolean removeByOutput(IIngredient output) {
return getRecipes().removeIf(r -> output.test(r.getOutput()) && addBackup(r));
return getRecipes().removeIf(r -> output.test(r.getOutput()) && doAddBackup(r));
}

@MethodDescription(example = @Example(value = "HydraulicPressMode.MEDIUM", imports = "com.cout970.magneticraft.api.registries.machines.hydraulicpress.HydraulicPressMode"))
public boolean removeByMode(HydraulicPressMode mode) {
return getRecipes().removeIf(r -> mode == r.getMode() && addBackup(r));
return getRecipes().removeIf(r -> mode == r.getMode() && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public Collection<IOilHeaterRecipe> getRecipes() {

@MethodDescription(example = @Example("fluid('oil')"))
public boolean removeByInput(IIngredient input) {
return getRecipes().removeIf(r -> input.test(r.getInput()) && addBackup(r));
return getRecipes().removeIf(r -> input.test(r.getInput()) && doAddBackup(r));
}

@MethodDescription(example = @Example("fluid('steam')"))
public boolean removeByOutput(IIngredient output) {
return getRecipes().removeIf(r -> output.test(r.getOutput()) && addBackup(r));
return getRecipes().removeIf(r -> output.test(r.getOutput()) && doAddBackup(r));
}

@Property(property = "fluidInput", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public Collection<IRefineryRecipe> getRecipes() {

@MethodDescription(example = @Example("fluid('steam')"))
public boolean removeByInput(IIngredient input) {
return getRecipes().removeIf(r -> input.test(r.getInput()) && addBackup(r));
return getRecipes().removeIf(r -> input.test(r.getInput()) && doAddBackup(r));
}

@MethodDescription(example = @Example("fluid('fuel')"))
public boolean removeByOutput(IIngredient output) {
return getRecipes().removeIf(r -> (output.test(r.getOutput0()) || output.test(r.getOutput1()) || output.test(r.getOutput2())) && addBackup(r));
return getRecipes().removeIf(r -> (output.test(r.getOutput0()) || output.test(r.getOutput1()) || output.test(r.getOutput2())) && doAddBackup(r));
}

@Property(property = "fluidInput", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public Collection<ISieveRecipe> getRecipes() {

@MethodDescription(example = @Example("item('minecraft:sand')"))
public boolean removeByInput(IIngredient input) {
return getRecipes().removeIf(r -> input.test(r.getInput()) && addBackup(r));
return getRecipes().removeIf(r -> input.test(r.getInput()) && doAddBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:quartz')"))
public boolean removeByOutput(IIngredient output) {
return getRecipes().removeIf(r -> (output.test(r.getPrimary()) || output.test(r.getSecondary()) || output.test(r.getTertiary())) && addBackup(r));
return getRecipes().removeIf(r -> (output.test(r.getPrimary()) || output.test(r.getSecondary()) || output.test(r.getTertiary())) && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public Collection<ISluiceBoxRecipe> getRecipes() {

@MethodDescription(example = @Example("item('minecraft:sand')"))
public boolean removeByInput(IIngredient input) {
return getRecipes().removeIf(r -> input.test(r.getInput()) && addBackup(r));
return getRecipes().removeIf(r -> input.test(r.getInput()) && doAddBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:cobblestone')"))
public boolean removeByOutput(IIngredient output) {
return getRecipes().removeIf(r -> r.getOutputs().stream().map(Pair::getFirst).anyMatch(output) && addBackup(r));
return getRecipes().removeIf(r -> r.getOutputs().stream().map(Pair::getFirst).anyMatch(output) && doAddBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Collection<IThermopileRecipe> getRecipes() {

@MethodDescription(example = @Example("blockstate('minecraft:ice')"))
public boolean removeByInput(IBlockState input) {
return getRecipes().removeIf(r -> input == r.getBlockState() && addBackup(r));
return getRecipes().removeIf(r -> input == r.getBlockState() && doAddBackup(r));
}

public static class RecipeBuilder extends AbstractRecipeBuilder<IThermopileRecipe> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public void onReload() {

@MethodDescription(type = MethodDescription.Type.ADDITION, description = "groovyscript.wiki.add_to_list", priority = 500)
public boolean add(R recipe) {
return recipe != null && getRecipes().add(recipe) && addScripted(recipe);
return recipe != null && getRecipes().add(recipe) && doAddScripted(recipe);
}

@MethodDescription(description = "groovyscript.wiki.remove_from_list", priority = 500)
public boolean remove(R recipe) {
return recipe != null && getRecipes().removeIf(r -> r == recipe) && addBackup(recipe);
return recipe != null && getRecipes().removeIf(r -> r == recipe) && doAddBackup(recipe);
}

@MethodDescription(priority = 2000, example = @Example(commented = true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,24 @@ public Collection<R> getScriptedRecipes() {
}

@GroovyBlacklist
public boolean addBackup(R recipe) {
public void addBackup(R recipe) {
doAddBackup(recipe);
}

@GroovyBlacklist
public void addScripted(R recipe) {
doAddScripted(recipe);
}

@ApiStatus.Experimental
@GroovyBlacklist
public boolean doAddBackup(R recipe) {
return recipeStorage.addBackup(recipe);
}

@ApiStatus.Experimental
@GroovyBlacklist
public boolean addScripted(R recipe) {
public boolean doAddScripted(R recipe) {
return recipeStorage.addScripted(recipe);
}

Expand Down

0 comments on commit 883efac

Please sign in to comment.