Posted March 1, 20169 yr Good evening, Using Forge 1.8.9 build 11.15.1.1722, I'm currently trying to create an item that acts like the furnace when rightclicking on it. (gui texture here) The use case of this item is the following : when rightclicking with this item, a gui is displayed with the player inventory and his hotbar. There are two slots that are unique to the item : an entry slot and an "exit" slot (concretely this is the same as the furnace except that it has two entry slots, the fuel and the things to burn/cook). When putting blocks in the entry slot, it starts the consumption : the consumption may end at any moment like quitting the gui or something else. At first try, I took a look at TheGreyGhost tutorial, BedrockMiner tutorial and coolAlias tutorial : I brained myself when I had to add a TileEntity to an Item which seems to be already set with an ItemStack. Since I don't need to save any data in the Item itself (the consumption is set when the player is using the item, there are no resources to store into slots...), are a Container and an Inventory sufficient to do it ? I ask this question because I'm not sure about storing/updating or not the consumption time, I don't know where to do it. What would be, according to you, the best way to achieve this ? Thank you for your time and your tips ! Squirrel ! Squirrel ! Squirrel !
March 1, 20169 yr you can store everything you need in the itemstacks nbt. I would save the time the "furnace" got opened last time in the nbt, and whenever the player opens the inventory process the items for actualTime-lastTimeOpened ticks
March 1, 20169 yr Author That's the trick : when the player quits the item interface, it stops the consumption. The items which were in the slots are dropped on the floor. Squirrel ! Squirrel ! Squirrel !
March 2, 20169 yr Author Good afternoon, I am bringing you some news. I learnt a lot from coolAlias tutorial and managed to understand some basic Container knowledges such as stacks transfers, slots indexes... I managed to make a nice lil' gui and it works perfectly for now. However, I still don't know how could I implement the consumption part for an Item. I don't need to store data when I close the Item gui : the player can only use the item when he's on it. I would need to store the consumption time, update it every tick and send some data to update the progress bar of the consumption, but all of this seems to be done in the TileEntity (for the furnace) and I don't fully understand how can I accomplish this for an Item. Could you give me some tips ? Following files : ModContainer.java ContainerSieve.java GuiSieve.java Squirrel ! Squirrel ! Squirrel !
March 2, 20169 yr To do something every tick from an Item , override Item#onUpdate . To store data for an Item , either use the NBT or the new Capability system. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
March 3, 20169 yr Author Hey again, I decided not to use the Item. I definitely wanted to try the block first, and now I'm facing a problem. I don't know which code to trigger on the server side and which one on the client side. Where do I have to register the GuiHandler, client or server ? EDIT: I just read diesieben07 explanation but I don't fully understand it. Squirrel ! Squirrel ! Squirrel !
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.