Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.cleanroommc.groovyscript.api.documentation.annotations.*;
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
import com.cleanroommc.groovyscript.helper.ingredient.GroovyScriptCodeConverter;
import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper;
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
Expand Down Expand Up @@ -65,12 +64,6 @@ public boolean remove(Recipe recipe) {

@MethodDescription(example = @Example("item('minecraft:clay:*')"))
public boolean removeByInput(IIngredient input) {
if (GroovyLog.msg("Error adding Minecraft Furnace recipe")
.add(IngredientHelper.isEmpty(input), () -> "Input must not be empty")
.error()
.postIfNotEmpty()) {
return false;
}
if (FurnaceRecipes.instance().getSmeltingList().entrySet().removeIf(entry -> {
if (input.test(entry.getKey())) {
addBackup(Recipe.of(entry.getKey(), entry.getValue()));
Expand All @@ -80,40 +73,29 @@ public boolean removeByInput(IIngredient input) {
})) {
return true;
}
var log = GroovyLog.msg("Error removing Minecraft Furnace recipe").error();
log.add("Can't find recipe for input " + input);
//noinspection ConstantValue
if ((Object) input instanceof ItemStack is && is.getMetadata() != OreDictionary.WILDCARD_VALUE) {
var wild = new ItemStack(is.getItem(), 1, OreDictionary.WILDCARD_VALUE);
if (!FurnaceRecipes.instance().getSmeltingResult(wild).isEmpty()) {
log.add("there was no input found for {}, but there was an input matching the wildcard itemstack {}", GroovyScriptCodeConverter.asGroovyCode(is, false), GroovyScriptCodeConverter.asGroovyCode(wild, false));
GroovyLog.msg("Error removing Minecraft Furnace recipe")
.debug()
.add("there was no input found for {}, but there was an input matching the wildcard itemstack {}", GroovyScriptCodeConverter.asGroovyCode(is, false), GroovyScriptCodeConverter.asGroovyCode(wild, false))
.add("did you mean to run furnace.removeByInput({}) instead?", GroovyScriptCodeConverter.asGroovyCode(wild, false))
.post();
}
}
log.post();
return false;
}

@MethodDescription(example = @Example("item('minecraft:brick')"))
public boolean removeByOutput(IIngredient output) {
if (GroovyLog.msg("Error adding Minecraft Furnace recipe")
.add(IngredientHelper.isEmpty(output), () -> "Output must not be empty")
.error()
.postIfNotEmpty()) {
return false;
}
if (FurnaceRecipes.instance().getSmeltingList().entrySet().removeIf(entry -> {
return FurnaceRecipes.instance().getSmeltingList().entrySet().removeIf(entry -> {
if (output.test(entry.getValue())) {
addBackup(Recipe.of(entry.getKey(), entry.getValue()));
return true;
}
return false;
})) {
return true;
}
GroovyLog.msg("Error removing Minecraft Furnace recipe")
.add("Can't find recipe for output " + output)
.error()
.post();
return false;
});
}

@MethodDescription(type = MethodDescription.Type.QUERY)
Expand Down