Siqhter Posted January 20, 2019 Share Posted January 20, 2019 (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 January 20, 2019 by Siqhter Quote Link to comment Share on other sites More sharing options...
ModMCdl Posted January 20, 2019 Share Posted January 20, 2019 (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 January 20, 2019 by ModMCdl 1 Quote 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 More sharing options...
Siqhter Posted January 20, 2019 Author Share Posted January 20, 2019 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? Quote Link to comment Share on other sites More sharing options...
ModMCdl Posted January 20, 2019 Share Posted January 20, 2019 (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 January 20, 2019 by ModMCdl Quote 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 More sharing options...
Siqhter Posted January 20, 2019 Author Share Posted January 20, 2019 Ok thanks. I have just been told to use an itemstackhandler and not use the vanilla "IInventory". I'll look through the git some more. Quote Link to comment Share on other sites More sharing options...
Cadiboo Posted January 21, 2019 Share Posted January 21, 2019 Use JSON for recipes, don’t hardcode them. It’s not hard and allows your users (and modpack makers) to customise your mod Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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 More sharing options...
Siqhter Posted January 21, 2019 Author Share Posted January 21, 2019 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. Quote Link to comment Share on other sites More sharing options...
Zamion101 Posted January 21, 2019 Share Posted January 21, 2019 Also you can use Hardcore and JSON together like reading data from JSON and turn into Harcode. Quote 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 More sharing options...
Cadiboo Posted January 21, 2019 Share Posted January 21, 2019 (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 January 21, 2019 by Cadiboo Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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 More sharing options...
Draco18s Posted January 21, 2019 Share Posted January 21, 2019 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. Quote 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 More sharing options...
ModMCdl Posted January 21, 2019 Share Posted January 21, 2019 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. Quote 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 More sharing options...
Cadiboo Posted January 21, 2019 Share Posted January 21, 2019 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. Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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 More sharing options...
Siqhter Posted January 23, 2019 Author Share Posted January 23, 2019 So then how would I tell the "SlotCrafting" class, (or whichever class responsible) to look for the json? Quote Link to comment Share on other sites More sharing options...
Draco18s Posted January 23, 2019 Share Posted January 23, 2019 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. Quote 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 More sharing options...
Siqhter Posted January 23, 2019 Author Share Posted January 23, 2019 1 hour ago, Draco18s said: or confused (slots don't "look for" json files). Yep it was confused. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.