Jump to content

New Crafting Table Type


Siqhter

Recommended Posts

Basically I'm trying to create a crafting system, where instead of creating a shape and getting a result in the 3x3 table, you open up the custom interface, put the two items in their respective slots and get the output. (e.g., instead of surrounding an apple with gold, put the gold in the first slot, apple in the second, and the result is a golden apple.) I've taken a look at ContainerWorkbench, but what really is the proper way to create a "crafting" slot that looks specifically for two items and provides you with a result?

 

I already have the interface working, gui, tileentity (which I might not need...) etc. Just wondering specifically about the crafting mechanic. Thanks.

Edited by Siqhter
Link to comment
Share on other sites

There is a specific class that defines the recipes for your new workbench block. I'll post a few of the key ideas below, but just know it's only to make the git I provide later on to make a little more sense for your situation.

 

In the recipes class, I "defined" recipes through a table:

private static final TwoByTwoRecipe INSTANCE = new TwoByTwoRecipes();
	private final Table<ItemStack, ItemStack, ItemStack> craftingList = HashBasedTable.<ItemStack, ItemStack, ItemStack>create();
      				// Item One  | Item Two | Result

The recipes would then be constructed as such:

addCustomRecipe(new ItemStack(Items.ItemOne), new ItemStack(Items.ItemTwo), new ItemStack(Items.Result));

Of which would call on:

public void addCustomRecipe(ItemStack input1, ItemStack input2, ItemStack result) 
	{
		if(getRecipeResult(input1, input2) != ItemStack.EMPTY) return;
		this.craftingList.put(input1, input2, result);
	}

A final method would compare the two results, and determine if the item can be crafted by checking each of the slots.

 

You can take a look at how I did it through the files here: https://github.com/CammiePone/Voidaic-Arcania/tree/master/src/main/java/com/camellias/voidaicarcania/common/blocks/machines/blockbotanyaltar , but be aware that the block is more based off of a furnace and requires a fuel. But you should be able to reverse engineer it based off of the examples above. It's interaction with the container should be relatively the same, but you can disregard the fuel requirements.

 

Edited by ModMCdl
  • Thanks 1

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

Thanks for the response, just to clarify it looks like you're using IInventory? Would it look much different to use IItemStackHandler? I just noticed this in your TileEntity as well as your container.

 

2nd question is, when you're adding a recipe, are you actually hardcoding that in the recipes java class, or do you then define it in json format?

Link to comment
Share on other sites

3 minutes ago, Siqhter said:

Would it look much different to use IItemStackHandler?

Not really sure, the way I do it has always worked fine for me, so I haven't yet explored other methods of doing it.

3 minutes ago, Siqhter said:

when you're adding a recipe, are you actually hardcoding that in the recipes java class, or do you then define it in json format?

The recipes are in the class, they don't rely on any secondary json.

 

Feel free to poke around the git a bit more if you want.

Edited by ModMCdl

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

Use JSON for recipes, don’t hardcode them. It’s not hard and allows your users (and modpack makers) to customise your mod

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

58 minutes ago, Zamion101 said:

Also you can use Hardcore and JSON together like reading data from JSON and turn into Harcode.

Hardcoded means that it is not customisable, json allows recipes to be dynamic, customisable and conditional

Edit: I just saw that you said “hardcore”, however I read it as “hardcode” and I assume that’s what you meant

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

53 minutes ago, Zamion101 said:

Also you can use Hardcore and JSON together like reading data from JSON and turn into Harcode.
 

Hardcore is not hard coded. Hard coded mean that the data is made up of magic numbers (strings, whatever) in the source code. This has nothing to do with "hard core" meaning very hard or advanced play.

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

19 hours ago, Cadiboo said:

Use JSON for recipes, don’t hardcode them. It’s not hard and allows your users (and modpack makers) to customise your mod

The only reason I hardcode is exactly for that reason. The items in my mods that I want the users to be able to customize are included in my mod's config file. 

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

45 minutes ago, ModMCdl said:

The only reason I hardcode is exactly for that reason. The items in my mods that I want the users to be able to customize are included in my mod's config file. 

What if a modpack maker wants to use an alternative way to craft your stuff in their pack? This would allow them to balance their pack, make a more interesting experience for their players etc. All recipes are moving to json in 1.13, it’s how it’s supposed to be done.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

1 hour ago, Siqhter said:

So then how would I tell the "SlotCrafting" class, (or whichever class responsible) to look for the json?

This question is either backwards (JSON files point to IRecipe implemenations) or confused (slots don't "look for" json files).

If you want to locate recipes, look at the list of recipes.

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.

×
×
  • Create New...

Important Information

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