Skip to content

Conversation

@Lordfirespeed
Copy link

@Lordfirespeed Lordfirespeed commented Aug 29, 2023

When an addon mod for Farmer's Delight (Farmer's Respite, Nether's Delight, etc) want to register a CuttingBoardRecipe or CookingPotRecipe, they cannot subclass the existing recipe builders as their constructors are private. That means developers are limited to

  • making an access transformer that modifies the recipe builders' constructor (access transformers do not work on other mods)
  • copy + pasting the implementation of the recipe builder (present solution 😭)

This PR enables subclassing the recipe builders, for example

package umpaz.nethersdelight.data.builder;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.ItemLike;

import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
class NethersDelightCookingPotRecipeBuilder extends CookingPotRecipeBuilder {
    protected NethersDelightCookingPotRecipeBuilder(ItemLike resultIn, int count, int cookingTime, float experience, @Nullable ItemLike container) {
        super(resultIn, count, cookingTime, experience, container);
    }

    public static NethersDelightCookingPotRecipeBuilder cookingPotRecipe(ItemLike mainResult, int count, int cookingTime, float experience) {
        return new NethersDelightCookingPotRecipeBuilder(mainResult, count, cookingTime, experience, null);
    }

    public static NethersDelightCookingPotRecipeBuilder cookingPotRecipe(ItemLike mainResult, int count, int cookingTime, float experience, ItemLike container) {
        return new NethersDelightCookingPotRecipeBuilder(mainResult, count, cookingTime, experience, container);
    }

    @Override
    protected String getDefaultRecipeName(ResourceLocation resultItemKey) {
        return "nethersdelight" + ":cooking/" + resultItemKey.getPath();
    }
}

This is achieved by making the constructors protected and providing an overridable method getDefaultRecipeName on each RecipeBuilder.

@Lordfirespeed Lordfirespeed changed the base branch from 1.19 to 1.20 August 29, 2023 22:17
@vectorwing vectorwing added the enhancement New feature or request label Aug 5, 2024
@vectorwing
Copy link
Owner

Hello! Sorry for the long delay, @Lordfirespeed. ^^

I suppose I could un-private the constructors for the builders. When they were written, I didn't consider that add-ons would be using them internally.

That said, what is the use case here? In your example, it seems you're simply using the builder without changes to its format; you can use different overrides for the .save() method to define specific namespaces and path names. Is the goal to simplify this process, or to accomodate a custom cooking recipe, with different parameters than vanilla FD?

@Lordfirespeed
Copy link
Author

Cor blimey, it's been a while on this - I remember I was working on nether's delight

I think the goal was to simplify the process - I'm not 100% sure about that

@vectorwing vectorwing changed the base branch from 1.20 to dev/1.3 February 8, 2026 23:44
@vectorwing vectorwing changed the base branch from dev/1.3 to 1.20 February 8, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants