Skip to content

Commit

Permalink
feat(1.21.2): Allow registration of recipe displays
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 18, 2024
1 parent 7659ea4 commit 534aa88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import net.minecraft.world.item.crafting.RecipeBookCategory;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.display.RecipeDisplay;

import java.util.function.Supplier;

public interface BalmRecipes {
<T extends Recipe<?>> DeferredObject<RecipeType<T>> registerRecipeType(Supplier<RecipeType<T>> typeSupplier, Supplier<RecipeSerializer<T>> serializerSupplier, ResourceLocation identifier);
<T extends RecipeDisplay.Type<?>> DeferredObject<T> registerRecipeDisplay(Supplier<T> supplier, ResourceLocation identifier);
DeferredObject<RecipeBookCategory> registerRecipeBookCategory(Supplier<RecipeBookCategory> supplier, ResourceLocation identifier);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.world.item.crafting.RecipeBookCategory;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.display.RecipeDisplay;

import java.util.function.Supplier;

Expand All @@ -28,4 +29,9 @@ public <T extends Recipe<?>> DeferredObject<RecipeType<T>> registerRecipeType(Su
public DeferredObject<RecipeBookCategory> registerRecipeBookCategory(Supplier<RecipeBookCategory> supplier, ResourceLocation identifier) {
return new DeferredObject<>(identifier, () -> Registry.register(BuiltInRegistries.RECIPE_BOOK_CATEGORY, identifier, supplier.get())).resolveImmediately();
}

@Override
public <T extends RecipeDisplay.Type<?>> DeferredObject<T> registerRecipeDisplay(Supplier<T> supplier, ResourceLocation identifier) {
return new DeferredObject<>(identifier, () -> Registry.register(BuiltInRegistries.RECIPE_DISPLAY, identifier, supplier.get())).resolveImmediately();
}
}

0 comments on commit 534aa88

Please sign in to comment.