Posted November 3, 20178 yr So this is a bit tricky. I know I've been spamming up the forums lately, but here's yet another problem I can't solve. I have successfully created a block and a GUI with container, however, I cannot get the custom crafting methods right. Essentially, I want to take two items and be able to combine them into one, but they don't craft. Nothing appears in the "result" slot, index 2. Image of GUI below for reference. My custom crafting class: https://github.com/ModMCdl/Magitech/blob/master/src/main/java/com/modmcdl/magitech/recipe/PestleRecipe.java My Tile Entity: https://github.com/ModMCdl/Magitech/blob/master/src/main/java/com/modmcdl/magitech/tileenitity/TileEntityPestle.java My Container: https://github.com/ModMCdl/Magitech/blob/master/src/main/java/com/modmcdl/magitech/gui/ContainerPestle.java My Block: https://github.com/ModMCdl/Magitech/blob/master/src/main/java/com/modmcdl/magitech/blocks/BlockPestle.java If another class is needed, they're all in the github there. Edited November 6, 20177 yr by ModMCdl Still not solved... 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
November 3, 20178 yr 1) Don't useIInventory. Use an IItemhandler (ItemStackHandler for most use-cases). 2) You never call TileEntityPestle#craftItem. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 3, 20178 yr why do you cast ItemStack here https://github.com/ModMCdl/Magitech/blob/master/src/main/java/com/modmcdl/magitech/tileenitity/TileEntityPestle.java#L106 i dont think you can use a HashBasedTable here because the hashcode from the itemstacks are different https://github.com/ModMCdl/Magitech/blob/master/src/main/java/com/modmcdl/magitech/recipe/PestleRecipe.java#L17
November 3, 20178 yr 21 minutes ago, loordgek said: i dont think you can use a HashBasedTable here because the hashcode from the itemstacks are different FurnaceRecipes uses a HashMap themselves so that's not the issue, because you never actually compare the hashcodes of the ItemStacks (HashMap#contains*()), just the ItemStacks themselves (going through the entry Set and compare them yourself). Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 3, 20178 yr Author 2 hours ago, loordgek said: why do you cast ItemStack here https://github.com/ModMCdl/Magitech/blob/master/src/main/java/com/modmcdl/magitech/tileenitity/TileEntityPestle.java#L106 i dont think you can use a HashBasedTable here because the hashcode from the itemstacks are different https://github.com/ModMCdl/Magitech/blob/master/src/main/java/com/modmcdl/magitech/recipe/PestleRecipe.java#L17 The ItemStack is referring to the two input slots in my TileEntity, and I pretty much frankensteined the code from the furnace, which uses the HasBasedTable. The reason I used this instead of the workbench was because I was a bit more familiar with TileEntities, and I could not find an example relating to the workbench that was newer than 1.7.10. (and I hate having to scour the web to find named versions of all the various unnamed funcs and fields). 2 hours ago, larsgerrits said: 1) Don't useIInventory. Use an IItemhandler (ItemStackHandler for most use-cases). 2) You never call TileEntityPestle#craftItem. I'll be honest, I'm confused. I can understand most of the reason behind using IItemHandler, but I don't understand where I need to call that TileEntity reference. This is a relatively new thing for me here, so I'm probably asking a stupid question. You reference that I never compare the hashcodes of my two ItemStacks. I'm confused as by how to exactly implement that. Could you possibly provide an example of where and when? 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
November 3, 20178 yr 1 minute ago, ModMCdl said: I don't understand where I need to call that TileEntity reference. Everywhere you want to trigger the crafting of the Item. If you want pestle to check for a crafting recipe every tick implement the ITickable interface on your TileEntityPestle and call it in the ITickable#update method. 5 minutes ago, ModMCdl said: You reference that I never compare the hashcodes of my two ItemStacks. I'm confused as by how to exactly implement that. Could you possibly provide an example of where and when? That was in response to @loordgek for suggesting the recipe class is at fault because of a hash-based solution. I told him that most likely wasn't the issue, as you aren't using the HashMap#contains*() functions to check for recipes, and so you never check based on the hash of the ItemStack. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 3, 20178 yr Author 14 minutes ago, larsgerrits said: Everywhere you want to trigger the crafting of the Item. If you want pestle to check for a crafting recipe every tick implement the ITickable interface on your TileEntityPestle and call it in the ITickable#update method. That was in response to @loordgek for suggesting the recipe class is at fault because of a hash-based solution. I told him that most likely wasn't the issue, as you aren't using the HashMap#contains*() functions to check for recipes, and so you never check based on the hash of the ItemStack. I tried overriding update, but It wouldn't let me. I'll check again, maybe I'm just an idiot. Was typing that when I decided to read the first part and implement ITickable. That's probably my issue here. I thought it wasn't necessary, because I wouldn't be using methods for smelting time and such. Also, are you saying I need to call my TileEntity in my custom crafting class, or call it through ITickable to check for new crafting items. (I know some of these questions are probably really stupid, but I'm just trying to learn here. This is new, and I couldn't find a decent tutorial or coherent example). 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
November 4, 20178 yr Author 1 hour ago, larsgerrits said: If you want pestle to check for a crafting recipe every tick implement the ITickable interface on your TileEntityPestle and call it in the ITickable#update method. Alright, after a lot of experimentation and fails, I can't quite figure out how this update thing works, or more precisely, how to make it work in my case. Could you please give an example?(Not asking for you to do it for me, more of like a brief rundown of how one would do it). Edited November 4, 20178 yr 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
November 4, 20178 yr 17 minutes ago, ModMCdl said: Alright, after a lot of experimentation and fails, I can't quite figure out how this update thing works, or more precisely, how to make it work in my case. Could you please give an example?(Not asking for you to do it for me, more of like a brief rundown of how one would do it). At the top of your class add "implements ITickable" Let your IDE underline it in red. Pick the only suggested solution that makes any sense "implement the interface") One of the methods added automatically will be one called Update 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.
November 4, 20178 yr Author 4 minutes ago, Draco18s said: At the top of your class add "implements ITickable" Let your IDE underline it in red. Pick the only suggested solution that makes any sense "implement the interface") One of the methods added automatically will be one called Update Yeah I got that. I'm just unsure what to do with it now. (As in what to call to specifically only update the recipes) 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
November 4, 20178 yr Look at the furnace. 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.
November 4, 20178 yr Author 1 minute ago, Draco18s said: Look at the furnace. I did, and I had omitted all of the "tickable" methods, because I didn't think they were needed unless I was doing some form of cooking? Would all I need from the furnace be the isRemote statement regarding the furnaceItemStacks, instead using that with my Pestle Recipes? Most of my code is frankensteined from the furnace, but I really have no idea what to do here. 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
November 4, 20178 yr If you're not cooking it over time, then you don't need ITickable. 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.
November 4, 20178 yr Author 2 minutes ago, Draco18s said: If you're not cooking it over time, then you don't need ITickable. That's what I thought, but now I'm lost. If you look above, I was informed I needed the update method to check the crafting recipe list each time I wanted to craft something. The only way to do this was through ITickable. Now, you're saying I don't need it, which puts me back to square one. Since you have never failed me before, Draco, (and if you haven't already), take a look at my original post and git and see if you can tell where I'm going wrong? 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
November 4, 20178 yr You don't need to check for a result every tick. You only need to do it when the inventory changes. 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.
November 4, 20178 yr Author 2 minutes ago, Draco18s said: You don't need to check for a result every tick. You only need to do it when the inventory changes. ...so what method would I call upon to do that, if not ITickable. Sorry, I feel stupid. Edited November 4, 20178 yr 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
November 4, 20178 yr 23 minutes ago, ModMCdl said: I was informed I needed the update method to check the crafting recipe list each time I wanted to craft something. The only way to do this was through ITickable I told you this: 2 hours ago, larsgerrits said: If you want pestle to check for a crafting recipe every tick implement the ITickable interface If you don't want to check every tick, don't implement ITickable. 9 minutes ago, ModMCdl said: so what method would I call upon to do that If you use an ItemStackHandler (again, use it instead of IInventory), you can make an anonymous subclass (is that what you call it?) or a normal subclass and override the ItemStackHandler#onContentsChanged method to call the TileEntityPestle#craftItem method. Edited November 4, 20178 yr by larsgerrits Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 4, 20178 yr Author Just now, larsgerrits said: I told you this: If you don't want to check every tick, don't implement ITickable. If you use an ItemStackHandler (again, use it instead of IInventory), you can make an anonymous subclass (is that what you call it?) or a normal subclass and override the ItemStackHandler#onContentsChanged method to call the TileEntityPestle#craftItem. So I have to re-write my old code with IItemHandler, which doesn't implement the same methods? Damn, that's gonna be a pain. 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
November 4, 20178 yr 5 minutes ago, ModMCdl said: So I have to re-write my old code with IItemHandler, which doesn't implement the same methods? Damn, that's gonna be a pain. Not really. It's way easier actually. Remove everything related to IInventory, and make a single instance of ItemStackHandler: public ItemStackHandler inventory = new ItemStackHandler(INVENTORY_SIZE); Everything related to the inventory is now inside that, and you can call various methods to interact with it. If you want other machines to be able to manipulate your inventory, look at the docs to see how to expose your capability. Edited November 4, 20178 yr by larsgerrits Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 4, 20178 yr Author 2 minutes ago, larsgerrits said: Remove everything related to IInventory, and make a single instance of ItemStackHandler: Se essentially replace my NonNullList with that? If I'm not mistaken, that's what would change my inventory instance? Because doing that errors almost every instance of inventory I use... 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
November 4, 20178 yr 9 minutes ago, ModMCdl said: Se essentially replace my NonNullList with that? Yes. 9 minutes ago, ModMCdl said: Because doing that errors almost every instance of inventory I use... Not only remove the "implements IInventory", but also every method you have to override from that. The only issues you'll have are in your TileEntityPestle#craftItem method and the ContainerPestle class. Take a look at my TileEntity class, it has an ItemStackHandler with anonymous subclass: https://gist.github.com/Larsg310/0bafea64ccac7280f32158dc52ead2a2 Edited November 4, 20178 yr by larsgerrits Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 4, 20178 yr Author 11 minutes ago, larsgerrits said: Yes. Not only remove the "implements IInventory", but also every method you have to override from that. The only issues you'll have are in your TileEntityPestle#craftItem method and the ContainerPestle class. Oh, I see. So I'm no longer overriding IInventory, but instead solely using ItemStackHandler. But now what do I do with the canCraft and craftItem methods? You mentioned issues, but wouldn't that completely error them out because they rely on all the methods from IInventory? Would I just replace .get with.getStackInSlot? And creategetInventoryStackLimit as my own method rather than an override? Then I could just cast all of the methods in my other classes to IInventory? Edited November 4, 20178 yr 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
November 4, 20178 yr You call ItemStackHandler#getStackInSlot instead of NonNullIList#get to get stuff out of your inventory. Instead of using the IInventory#getInventoryStackLimit method, you should override ItemStackHandler#getSlotLimit inside of an (anonymous) subclass of ItemStackHandler. Take a look at my previous edit for a link in which I do the same. Edited November 4, 20178 yr by larsgerrits Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 4, 20178 yr Author 14 minutes ago, larsgerrits said: Instead of using the IInventory#getInventoryStackLimit method, you should override ItemStackHandler#getSlotLimit inside of an (anonymous) subclass of ItemStackHandler. Take a look at my previous edit for a link in which I do the same. Alright, but what do I do about all of my other classes? My Container, GUI, and Block were all built around the original version. Am I casting those toIInventory? And what about my block'scanInteractWith? Edited November 4, 20178 yr 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
November 4, 20178 yr 46 minutes ago, ModMCdl said: Alright, but what do I do about all of my other classes? My Container, GUI, and Block were all built around the original version. Am I casting those toIInventory? And what about my block'scanInteractWith? Instead of using Slot you use SlotItemHandler and instead of casting to IInventory you use getCapability(). 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.