Jump to content

[1.12.2] Unlock recipes in RecipeBook


Maefvfis

Recommended Posts

Hiho,

im working on a mod and a feature should be to unlock all recipes in the recipe book.
So far i found out how to add the recipes to the book, but they didnt show up until i recive a advancement.
 

ArrayList<IRecipe> recipes = new ArrayList();
for (IRecipe irecipe : net.minecraftforge.registries.GameData.getWrapper(IRecipe.class)) {
    recipes.add(irecipe);
}
Minecraft.getMinecraft().player.unlockRecipes(recipes);

 

Thx for any help :)

Link to comment
Share on other sites

Hey, first of all thx for your reply!

My approaches are allways a bit bodgy. I put things together and dont question them as long as they are working.
Now i red the comment u mentioned.

 

I pasted the wrong line of code... i had a bit of a mess with this bit as i was trying different things, sorry for that. ( The ForgeRegistries.RECIPES is now there thx to you)

The partly working code is this:

RecipeBook book = new RecipeBook();
for (IRecipe irecipe : ForgeRegistries.RECIPES) {
	book.unlock(irecipe);
}
Minecraft.getMinecraft().player.getRecipeBook().copyFrom(book);

 

almost what i want...

When i stat a new world, i have no recipes. Then i execute the code. Nothing happens. But then i pick up a log, get the new recipes from that and the ones from the code aswell.
 

Thx in advance :)

Link to comment
Share on other sites

1 minute ago, Maefvfis said:

When i stat a new world, i have no recipes. Then i execute the code. Nothing happens. But then i pick up a log, get the new recipes from that and the ones from the code aswell.

Probably because you're still doing it client side.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Btw. if i lock the recipes instead of unlocking it works like a charm.

RecipeBook book = new RecipeBook();
for (IRecipe irecipe : ForgeRegistries.RECIPES) {
	book.lock(irecipe);
}
Minecraft.getMinecraft().player.getRecipeBook().copyFrom(book);

All recipes gone... ^^

Link to comment
Share on other sites

Maybe i should have clarified it a bit more, beforehand.
When your in the inventory, you have the crafting book.
I want that all recipes are available to craft (in bench aswell) without first unlocking them through gathering the resources to craft them.

 

Yeah, thats basicly it

Edited by Maefvfis
Link to comment
Share on other sites

I see, that clarified things for me.

Didnt know about the "server wont let me" thing.
The mod should function an all server, not espacially mine.
Well i guess than i´ll build some sort of ingame quest guide to help getting the recipes.

 

Vielen Dank!

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

That would un-hide the recipes, yes. But it would just show them in the GUI, that is all. By all intents and purposes you still have not unlocked those recipes and the server will not let you use them.

Technically that's an option that is disabled by default.

doLimitedCrafting Whether players should only be able to craft recipes that they've unlocked first false
Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.

Announcements



×
×
  • Create New...

Important Information

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