MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a recipe"
-- First, create an instance of your recipe serializer class that extends net.minecraft.item.crafting.IRecipeSerializer. Then, create a class that extends net.minecraft.item.crafting.SpecialRecipe that implements the recipe logic. Finally, register your recipe serializer and recipe with the forge registry public class MyRecipeSerializer extends net.minecraft.item.crafting.IRecipeSerializer<MyRecipe> { @Override public MyRecipe read(ResourceLocation recipeId, JsonObject json) { // read recipe from json } @Override public MyRecipe read(ResourceLocation recipeId, PacketBuffer buffer) { // read recipe from packet buffer } @Override public void write(PacketBuffer buffer, MyRecipe recipe) { // write recipe to packet buffer } } public class MyRecipe extends net.minecraft.item.crafting.SpecialRecipe { public MyRecipe(ResourceLocation idIn) { super(idIn); } @Override public boolean matches(Inventory inv, World worldIn) { // check if recipe matches inventory contents } @Override public ItemStack getCraftingResult(Inventory inv) { // return the resulting item stack } @Override public boolean canFit(int width, int height) { // check if recipe can fit in crafting grid } @Override public IRecipeSerializer<?> getSerializer() { return MyRecipeSerializer.INSTANCE; } } // Register the recipe serializer and recipe with the forge registry ForgeRegistries.RECIPE_SERIALIZERS.register(MyRecipeSerializer.INSTANCE.setRegistryName(new ResourceLocation("my_mod", "my_recipe"))); ForgeRegistries.RECIPES.register(new MyRecipe(new ResourceLocation("my_mod", "my_recipe")));