diff --git a/fabric/src/main/java/net/blay09/mods/balm/fabric/recipe/FabricBalmRecipes.java b/fabric/src/main/java/net/blay09/mods/balm/fabric/recipe/FabricBalmRecipes.java index d7a0ee41..01248cd6 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/fabric/recipe/FabricBalmRecipes.java +++ b/fabric/src/main/java/net/blay09/mods/balm/fabric/recipe/FabricBalmRecipes.java @@ -6,6 +6,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import java.util.function.Supplier; @@ -13,9 +14,10 @@ public class FabricBalmRecipes implements BalmRecipes { @Override - public > DeferredObject> registerRecipeType(Supplier> supplier, ResourceLocation identifier) { + public > DeferredObject> registerRecipeType(Supplier> typeSupplier, Supplier> serializerSupplier, ResourceLocation identifier) { return new DeferredObject<>(identifier, () -> { - RecipeType recipeType = supplier.get(); + Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, identifier, serializerSupplier.get()); + RecipeType recipeType = typeSupplier.get(); recipeType = Registry.register(BuiltInRegistries.RECIPE_TYPE, identifier, recipeType); return recipeType; }).resolveImmediately(); diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/recipe/ForgeBalmRecipes.java b/forge/src/main/java/net/blay09/mods/balm/forge/recipe/ForgeBalmRecipes.java index 5fb1df61..964a7dea 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/recipe/ForgeBalmRecipes.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/recipe/ForgeBalmRecipes.java @@ -5,6 +5,7 @@ import net.blay09.mods.balm.forge.DeferredRegisters; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -14,10 +15,14 @@ public class ForgeBalmRecipes implements BalmRecipes { @Override - public > DeferredObject> registerRecipeType(Supplier> supplier, ResourceLocation identifier) { - DeferredRegister> register = DeferredRegisters.get(ForgeRegistries.RECIPE_TYPES, identifier.getNamespace()); - RegistryObject> registryObject = register.register(identifier.getPath(), supplier); - return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); + public > DeferredObject> registerRecipeType(Supplier> typeSupplier, Supplier> serializerSupplier, ResourceLocation identifier) { + DeferredRegister> serializerRegister = DeferredRegisters.get(ForgeRegistries.RECIPE_SERIALIZERS, identifier.getNamespace()); + RegistryObject> serializerObject = serializerRegister.register(identifier.getPath(), serializerSupplier); + + DeferredRegister> typeRegister = DeferredRegisters.get(ForgeRegistries.RECIPE_TYPES, identifier.getNamespace()); + RegistryObject> typeObject = typeRegister.register(identifier.getPath(), typeSupplier); + + return new DeferredObject<>(identifier, typeObject, () -> typeObject.isPresent() && serializerObject.isPresent()); } } diff --git a/neoforge/src/main/java/net/blay09/mods/balm/neoforge/recipe/NeoForgeBalmRecipes.java b/neoforge/src/main/java/net/blay09/mods/balm/neoforge/recipe/NeoForgeBalmRecipes.java index 8c64ef20..08e8a71e 100644 --- a/neoforge/src/main/java/net/blay09/mods/balm/neoforge/recipe/NeoForgeBalmRecipes.java +++ b/neoforge/src/main/java/net/blay09/mods/balm/neoforge/recipe/NeoForgeBalmRecipes.java @@ -6,16 +6,21 @@ import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import java.util.function.Supplier; public class NeoForgeBalmRecipes implements BalmRecipes { @Override - public > DeferredObject> registerRecipeType(Supplier> supplier, ResourceLocation identifier) { + public > DeferredObject> registerRecipeType(Supplier> typeSupplier, Supplier> serializerSupplier, ResourceLocation identifier) { final var register = DeferredRegisters.get(Registries.RECIPE_TYPE, identifier.getNamespace()); - final var registryObject = register.register(identifier.getPath(), supplier); - return new DeferredObject<>(identifier, registryObject, registryObject::isBound); + final var registryObject = register.register(identifier.getPath(), typeSupplier); + + final var serializerRegister = DeferredRegisters.get(Registries.RECIPE_SERIALIZER, identifier.getNamespace()); + final var serializerRegistryObject = serializerRegister.register(identifier.getPath(), serializerSupplier); + + return new DeferredObject<>(identifier, registryObject, () -> registryObject.isBound() && serializerRegistryObject.isBound()); } } diff --git a/shared/src/main/java/net/blay09/mods/balm/api/Balm.java b/shared/src/main/java/net/blay09/mods/balm/api/Balm.java index 85c6fb91..90a4da61 100644 --- a/shared/src/main/java/net/blay09/mods/balm/api/Balm.java +++ b/shared/src/main/java/net/blay09/mods/balm/api/Balm.java @@ -12,6 +12,7 @@ import net.blay09.mods.balm.api.network.BalmNetworking; import net.blay09.mods.balm.api.provider.BalmProviders; import net.blay09.mods.balm.api.proxy.SidedProxy; +import net.blay09.mods.balm.api.recipe.BalmRecipes; import net.blay09.mods.balm.api.sound.BalmSounds; import net.blay09.mods.balm.api.stats.BalmStats; import net.blay09.mods.balm.api.world.BalmWorldGen; @@ -99,6 +100,10 @@ public static BalmHooks getHooks() { return runtime.getHooks(); } + public static BalmRecipes getRecipes() { + return runtime.getRecipes(); + } + public static BalmRegistries getRegistries() { return runtime.getRegistries(); } diff --git a/shared/src/main/java/net/blay09/mods/balm/api/recipe/BalmRecipes.java b/shared/src/main/java/net/blay09/mods/balm/api/recipe/BalmRecipes.java index 4827b686..28425d84 100644 --- a/shared/src/main/java/net/blay09/mods/balm/api/recipe/BalmRecipes.java +++ b/shared/src/main/java/net/blay09/mods/balm/api/recipe/BalmRecipes.java @@ -3,10 +3,11 @@ import net.blay09.mods.balm.api.DeferredObject; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import java.util.function.Supplier; public interface BalmRecipes { - > DeferredObject> registerRecipeType(Supplier> supplier, ResourceLocation identifier); + > DeferredObject> registerRecipeType(Supplier> typeSupplier, Supplier> serializerSupplier, ResourceLocation identifier); }