-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70633fc
commit a64c3bc
Showing
8 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
fabric/src/main/java/net/blay09/mods/balm/fabric/recipe/FabricBalmRecipes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net.blay09.mods.balm.fabric.recipe; | ||
|
||
import net.blay09.mods.balm.api.DeferredObject; | ||
import net.blay09.mods.balm.api.recipe.BalmRecipes; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.crafting.Recipe; | ||
import net.minecraft.world.item.crafting.RecipeType; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class FabricBalmRecipes implements BalmRecipes { | ||
|
||
@Override | ||
public <T extends Recipe<?>> DeferredObject<RecipeType<T>> registerRecipeType(Supplier<RecipeType<T>> supplier, ResourceLocation identifier) { | ||
return new DeferredObject<>(identifier, () -> { | ||
RecipeType<T> recipeType = supplier.get(); | ||
recipeType = Registry.register(BuiltInRegistries.RECIPE_TYPE, identifier, recipeType); | ||
return recipeType; | ||
}).resolveImmediately(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
forge/src/main/java/net/blay09/mods/balm/forge/recipe/ForgeBalmRecipes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.blay09.mods.balm.forge.recipe; | ||
|
||
import net.blay09.mods.balm.api.DeferredObject; | ||
import net.blay09.mods.balm.api.recipe.BalmRecipes; | ||
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.RecipeType; | ||
import net.minecraftforge.registries.DeferredRegister; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import net.minecraftforge.registries.RegistryObject; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class ForgeBalmRecipes implements BalmRecipes { | ||
@Override | ||
public <T extends Recipe<?>> DeferredObject<RecipeType<T>> registerRecipeType(Supplier<RecipeType<T>> supplier, ResourceLocation identifier) { | ||
DeferredRegister<RecipeType<?>> register = DeferredRegisters.get(ForgeRegistries.RECIPE_TYPES, identifier.getNamespace()); | ||
RegistryObject<RecipeType<T>> registryObject = register.register(identifier.getPath(), supplier); | ||
return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
neoforge/src/main/java/net/blay09/mods/balm/neoforge/recipe/NeoForgeBalmRecipes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.blay09.mods.balm.neoforge.recipe; | ||
|
||
import net.blay09.mods.balm.api.DeferredObject; | ||
import net.blay09.mods.balm.api.recipe.BalmRecipes; | ||
import net.blay09.mods.balm.neoforge.DeferredRegisters; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.crafting.Recipe; | ||
import net.minecraft.world.item.crafting.RecipeType; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
import net.neoforged.neoforge.registries.ForgeRegistries; | ||
import net.neoforged.neoforge.registries.RegistryObject; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class NeoForgeBalmRecipes implements BalmRecipes { | ||
@Override | ||
public <T extends Recipe<?>> DeferredObject<RecipeType<T>> registerRecipeType(Supplier<RecipeType<T>> supplier, ResourceLocation identifier) { | ||
DeferredRegister<RecipeType<?>> register = DeferredRegisters.get(ForgeRegistries.RECIPE_TYPES, identifier.getNamespace()); | ||
RegistryObject<RecipeType<T>> registryObject = register.register(identifier.getPath(), supplier); | ||
return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
shared/src/main/java/net/blay09/mods/balm/api/recipe/BalmRecipes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package net.blay09.mods.balm.api.recipe; | ||
|
||
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.RecipeType; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public interface BalmRecipes { | ||
<T extends Recipe<?>> DeferredObject<RecipeType<T>> registerRecipeType(Supplier<RecipeType<T>> supplier, ResourceLocation identifier); | ||
} |