Sicmish Posted September 16, 2017 Posted September 16, 2017 (edited) Could any tell me how I would return a empty bottle after crafting instead of destroying it. { "type": "minecraft:crafting_shaped", "pattern": [ " ", "S ", "FW " ], "key": { "S": { "item": "minecraft:sugar" }, "F": { "item": "sicmish:flour" }, "W": { "item": "minecraft:potion" //Retun glass_bottle } }, "result": { "item": "sicmish:dough" } } Edited September 16, 2017 by Sicmish Quote
Choonster Posted September 16, 2017 Posted September 16, 2017 You'll need a custom recipe type that implements IRecipe#getRemainingItems to return a list of remaining items, using the container item (ForgeHooks.getContainerItem) for every slot except the one with the potion in it, which you'll use an empty bottle for instead. I recommend extending ShapedRecipes or ShapedOreRecipes so you don't have to re-implement everything yourself. To use this new recipe type from JSON recipe files, you'll need to create a class that implements IRecipeFactory to parse the recipe from the supplied JSON object. Specify this factory class in your recipes/_factories.json file. Look at the CraftingHelper.init method to see the IRecipeFactory implementations for the Vanilla and Forge recipe types. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Sicmish Posted September 16, 2017 Author Posted September 16, 2017 (edited) 12 minutes ago, Choonster said: You'll need a custom recipe type that implements IRecipe#getRemainingItems to return a list of remaining items, using the container item (ForgeHooks.getContainerItem) for every slot except the one with the potion in it, which you'll use an empty bottle for instead. I recommend extending ShapedRecipes or ShapedOreRecipes so you don't have to re-implement everything yourself. To use this new recipe type from JSON recipe files, you'll need to create a class that implements IRecipeFactory to parse the recipe from the supplied JSON object. Specify this factory class in your recipes/_factories.json file. Look at the CraftingHelper.init method to see the IRecipeFactory implementations for the Vanilla and Forge recipe types. Well I really appreciate the help! but that is a lot to try and figure out lol. But I did find a way to over ride the json in a way(Don't really know if this is overriding/over looking the recipe.json). I just had to make sure the recipes were the same. ItemStack recipeOutput = new ItemStack(SicmishItems.dough, 1); GameRegistry.addShapedRecipe(new ResourceLocation(Reference.MOD_ID, "dough.recipe"), null, recipeOutput, new String[] { " ", "S ", "FW " }, 'S', net.minecraft.init.Items.SUGAR, 'F', SicmishItems.flour, 'W', net.minecraft.init.Items.POTIONITEM.setContainerItem(net.minecraft.init.Items.GLASS_BOTTLE) ); Again thanks for the help! Edited September 16, 2017 by Sicmish Quote
Choonster Posted September 16, 2017 Posted September 16, 2017 Item#setContainerItem sets the container item for that Item instance globally, which means it now returns that item in every recipe rather than just yours. This probably isn't what you want to do. Either specify the recipe in a JSON file (recommended) or specify it in code, don't do both. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Sicmish Posted September 16, 2017 Author Posted September 16, 2017 56 minutes ago, Choonster said: Item#setContainerItem sets the container item for that Item instance globally, which means it now returns that item in every recipe rather than just yours. This probably isn't what you want to do. Either specify the recipe in a JSON file (recommended) or specify it in code, don't do both. You was absolutely right about that! Hmm, well I think I'm way to new to the minecraft/forge extension to try and jump in this kind of project I think I'll just keep it simple for now. Build op some knowledge before I tackle that. Thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.