Jump to content

Recommended Posts

Posted (edited)

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
Posted (edited)

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

Posted

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?

Posted (edited)
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

Posted

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)

Posted
15 hours ago, Cadiboo said:

Use JSON for recipes, don’t hardcode them.

Ok, I was wondering about customization, and hardcoding it didn't seem quite right. Thanks.

Posted (edited)
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)

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

Posted
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

Posted
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)

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

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
×
×
  • Create New...

Important Information

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