Jump to content

[1.12.1] Crafting with water bottle, return empty bottle


Sicmish

Recommended Posts

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 by Sicmish
Link to comment
Share on other sites

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.

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.

Link to comment
Share on other sites

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 by Sicmish
Link to comment
Share on other sites

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.

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.