Skip to content

Commit

Permalink
feat: allow excluding specific recipes or whole result item groups #649
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jan 9, 2024
1 parent 568fc7c commit 04be79a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import net.blay09.mods.balm.api.config.BalmConfigData;
import net.blay09.mods.balm.api.config.Comment;
import net.blay09.mods.balm.api.config.Config;
import net.blay09.mods.balm.api.config.ExpectedType;
import net.minecraft.resources.ResourceLocation;

import java.util.Set;

@Config(CookingForBlockheads.MOD_ID)
public class CookingForBlockheadsConfigData implements BalmConfigData {
Expand Down Expand Up @@ -39,4 +43,8 @@ public class CookingForBlockheadsConfigData implements BalmConfigData {

@Comment("Toasting toasted bread again will turn into charcoal (only if no other mod adding toast is present). Set to false to disable.")
public boolean allowVeryToastedBread = true;

@Comment("List of recipe ids that should be excluded from the recipe book.")
@ExpectedType(ResourceLocation.class)
public Set<ResourceLocation> excludedRecipes = Set.of();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.blay09.mods.balm.api.event.client.RecipesUpdatedEvent;
import net.blay09.mods.balm.api.event.server.ServerReloadFinishedEvent;
import net.blay09.mods.balm.api.event.server.ServerStartedEvent;
import net.blay09.mods.cookingforblockheads.CookingForBlockheadsConfig;
import net.blay09.mods.cookingforblockheads.api.ISortButton;
import net.blay09.mods.cookingforblockheads.api.KitchenRecipeGroup;
import net.blay09.mods.cookingforblockheads.api.KitchenRecipeHandler;
Expand Down Expand Up @@ -73,11 +74,15 @@ public static List<KitchenRecipeGroup> getGroups() {
}

private static boolean isEligibleResultItem(ItemStack itemStack) {
if (itemStack.is(ModItemTags.EXCLUDED)) {
return false;
}

return itemStack.isEdible() || itemStack.is(ModItemTags.FOODS) || itemStack.is(ModItemTags.INGREDIENTS);
}

private static <T extends Container> boolean isEligibleRecipe(RecipeHolder<? extends Recipe<T>> recipe) {
return true;
return !CookingForBlockheadsConfig.getActive().excludedRecipes.contains(recipe.id());
}

public static <C extends Container, T extends Recipe<C>> void registerKitchenRecipeHandler(Class<T> recipeType, KitchenRecipeHandler<T> handler) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public class ModItemTags {
public static final TagKey<Item> INGREDIENTS = TagKey.create(Registries.ITEM, new ResourceLocation(CookingForBlockheads.MOD_ID, "ingredients"));
public static final TagKey<Item> MILK = TagKey.create(Registries.ITEM, new ResourceLocation(CookingForBlockheads.MOD_ID, "milk"));
public static final TagKey<Item> WATER = TagKey.create(Registries.ITEM, new ResourceLocation(CookingForBlockheads.MOD_ID, "water"));
public static final TagKey<Item> EXCLUDED = TagKey.create(Registries.ITEM, new ResourceLocation(CookingForBlockheads.MOD_ID, "excluded"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,8 @@
"config.cookingforblockheads.showIngredientIcon": "Show Ingredient Icon",
"config.cookingforblockheads.showIngredientIcon.tooltip": "Set to false if you don't want ingredients to be marked with a special icon in the recipe book.",
"config.cookingforblockheads.allowVeryToastedBread": "Allow Very Toasted Bread",
"config.cookingforblockheads.allowVeryToastedBread.tooltip": "Toasting toasted bread again will turn into charcoal (only if no other mod adding toast is present). Set to false to disable."
"config.cookingforblockheads.allowVeryToastedBread.tooltip": "Toasting toasted bread again will turn into charcoal (only if no other mod adding toast is present). Set to false to disable.",
"config.cookingforblockheads.excludedRecipes": "Excluded Recipes",
"config.cookingforblockheads.excludedRecipes.tooltip": "List of recipe ids that should be excluded from the recipe book."

}

0 comments on commit 04be79a

Please sign in to comment.