Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.12] Removing vanilla Recipes


kirinnee97
 Share

Recommended Posts

The recipe registry (unlike other registries) is modifiable, so you can actually remove a recipe using IForgeRegistryModifiable#remove.

 

Any advancement that rewards the recipe will throw a syntax exception (spamming the log) if you do this, though.

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

15 minutes ago, Choonster said:

The recipe registry (unlike other registries) is modifiable, so you can actually remove a recipe using IForgeRegistryModifiable#remove.

 

Any advancement that rewards the recipe will throw a syntax exception (spamming the log) if you do this, though.

I accessed the registries both using the RegistryEvent and ForgeRegistries and access the recipe registry (ForgeRegistries.RECIPES) and tried removing, but it throws a 

java.lang.UnsupportedOperationException: remove

Link to comment
Share on other sites

9 minutes ago, kirinnee97 said:

I accessed the registries both using the RegistryEvent and ForgeRegistries and access the recipe registry (ForgeRegistries.RECIPES) and tried removing, but it throws a 

java.lang.UnsupportedOperationException: remove

 

Which version of Forge are you using? Post your code and the full stacktrace of the exception.

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

7 minutes ago, Choonster said:

 

Which version of Forge are you using? Post your code and the full stacktrace of the exception.

Hi, I'm sorry for the confusion, it seems I did not cast to  IForgeRegistryModifiable. As you said, it works but throws exceptions, but replacing with no-op implementation doesn't, so i think i will go with diesieben's method! Thank you very much with your help this time again!

Link to comment
Share on other sites

Hello kririnee. I'm fairly new to java programing and even newer if we speak about mod writing.

Would you mind uploading your code?(where u use the no-op implementation) Because I need it and I have literally no clue how to do it, and not found a single word about it on google... 

Thanks!

Link to comment
Share on other sites

On 7/5/2017 at 2:29 AM, Tiesto97 said:

Hello kririnee. I'm fairly new to java programing and even newer if we speak about mod writing.

Would you mind uploading your code?(where u use the no-op implementation) Because I need it and I have literally no clue how to do it, and not found a single word about it on google... 

Thanks!

Hi sorry for the late reply, and no-op implementation in Java essentially means a "dummy", or fake object. Its a dummy that implements an interface. Simply put, all you have to do is create a class that implements IRecipe, override its method properly, and create and object of that class. You then register that object with the minecraft vanilla object's registry name. Hope it helps.

Link to comment
Share on other sites

I was trying to use this to remove a recipe (not a vanilla recipe) however this doesn't seem to be allowed.

 

			if (ForgeRegistries.RECIPES.containsValue(recipe)) {
				ForgeRegistries.RECIPES.getEntries().remove(recipe);
			}

 

I'll try replacing it instead.

Link to comment
Share on other sites

4 hours ago, Arimil said:

I was trying to use this to remove a recipe (not a vanilla recipe) however this doesn't seem to be allowed.

 


			if (ForgeRegistries.RECIPES.containsValue(recipe)) {
				ForgeRegistries.RECIPES.getEntries().remove(recipe);
			}

 

I'll try replacing it instead.

 

ForgeRegistry#getEntries returns an immutable copy of the registry's entries, so you can't use it to modify the registry.

 

As I said earlier in the thread, use IForgeRegistryModifiable#remove.

Edited by Choonster
  • Like 1

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

I have a 2-3 years of Java knowledge and have 1.5 years of Spigot / Bukkit. But i want to learn Forge so i decided to create a mod. And i want remove some vanilla recipes but i don't understand what i need do can anybody help me ?

 

Developing Kodev Minecraft Hardcore Mod!

If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod

Link to comment
Share on other sites

I know what he said but i can't understand this message i need Extends? or anything?

 

I write this lines of code:


        Iterator<IRecipe> rec = ForgeRegistries.RECIPES.iterator();
        IForgeRegistryModifiable<IRecipe> r = (IForgeRegistryModifiable<IRecipe>) rec.next();
        r.remove(Items.STICK.getRegistryName());

 

I think i do error because not crashing game but not removing too.

Developing Kodev Minecraft Hardcore Mod!

If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod

Link to comment
Share on other sites

Okey ı understand now and i fixed my error thank you so much and i give here the my code for everyone.
@diesieben07 Thank you...

 

/*POST-INIT*/
new RecipeManager(Items.STICK);
or
new RecipeManager(Blocks.GOLD_BLOCK);

/*RECIPE MANAGER*/

public class RecipeManager extends ForgeRegistries{
	
	public RecipeManager(Item item){
		 ForgeRegistry<IRecipe> r = (ForgeRegistry<IRecipe>) RECIPES;
		 r.remove(item.getRegistryName());
		 CraftingHelper.loadRecipes(false);
		 CraftingManager.init();
	}
	public RecipeManager(ItemStack itemStack){
		 ForgeRegistry<IRecipe> r = (ForgeRegistry<IRecipe>) RECIPES;
		 r.remove(itemStack.getItem().getRegistryName());
		 CraftingHelper.loadRecipes(false);
		 CraftingManager.init();
	}
	public RecipeManager(Block block){
		 ForgeRegistry<IRecipe> r = (ForgeRegistry<IRecipe>) RECIPES;
		 r.remove(Item.getItemFromBlock(block).getRegistryName());
		 CraftingHelper.loadRecipes(false);
		 CraftingManager.init();
	}

}

 

Developing Kodev Minecraft Hardcore Mod!

If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod

Link to comment
Share on other sites

  • Why on earth are you doing this in constructors? O.o
  • Why do you extend ForgeRegistriesO.o
  • Why are you calling CraftingHelper.loadRecipes and CraftingManager.init? You should not be calling either, ever.
  • Do not use the ForgeRegistry class, use the interfaces IForgeRegistry resp. IForgeRegistryModifiable.
Link to comment
Share on other sites

20 minutes ago, diesieben07 said:
  • Why on earth are you doing this in constructors? O.o
  • Why do you extend ForgeRegistriesO.o
  • Why are you calling CraftingHelper.loadRecipes and CraftingManager.init? You should not be calling either, ever.
  • Do not use the ForgeRegistry class, use the interfaces IForgeRegistry resp. IForgeRegistryModifiable.
  • Because i want.
  • Because IDK :D
  • Because if you don't call CraftingHelper.loadRecipes crashing game when open crafting table or player inventory.
  • Next time. Now don't have a any error.

Developing Kodev Minecraft Hardcore Mod!

If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod

Link to comment
Share on other sites

Just now, Zamion101 said:

Because i want.

It makes no sense.

 

Just now, Zamion101 said:

Because if you don't call CraftingHelper.loadRecipes crashing game when open crafting table or player inventory.

Show that crash. When exactly (i.e. which loading phase / event) are you removing these recipes?

 

1 minute ago, Zamion101 said:

Next time. Now don't have a any error.

No, not next time. This is a problem.

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.