HalestormXV

RecipeSerializerInit

Oct 25th, 2020
651
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class RecipeSerializerInit {
  2.     //Declarations
  3.     public static final IRecipeSerializer<LunariumDustRecipe> LUNAR_FORGE_RECIPE_SERIALIZER = new LunariumDustRecipeSerializer();
  4.     public static final IRecipeType<ILunariumDustRecipe> LUNAR_FORGE_TYPE = registerType(ILunariumDustRecipe.RECIPE_TYPE_ID);
  5.  
  6.     //Deferred Creation
  7.     public static final DeferredRegister<IRecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, MysteriumMain.MOD_ID);
  8.  
  9.     //The Recipe Objects
  10.     public static final RegistryObject<IRecipeSerializer<?>> LUNAR_FORGE_SERIALIZER = RECIPE_SERIALIZERS.register("lunarium_dust", () -> LUNAR_FORGE_RECIPE_SERIALIZER);
  11.  
  12.     //Private Methods to make it Work
  13.     private static class RecipeType<T extends IRecipe<?>> implements IRecipeType<T> {
  14.         @Override
  15.         public String toString() {
  16.             return Registry.RECIPE_TYPE.getKey(this).toString();
  17.         }
  18.     }
  19.  
  20.     private static <T extends IRecipeType> T registerType(ResourceLocation recipeTypeId) {
  21.         return (T) Registry.register(Registry.RECIPE_TYPE, recipeTypeId, new RecipeType<>());
  22.     }
  23. }
RAW Paste Data