Posted May 18, 20178 yr I know this is a really dumb question but I wondered if I can cast from IInventory to IItemHandler. Because it has some methods that use IInventory instead of the IItemHandler capability system. Like Container#onCraftMatrixChanged, IContainerListener#sendAllWindowProperties.,... I would greatly appreciated your help!
May 18, 20178 yr No. IItemHandler, and IInventory are both interfaces, that both do similar things, but in the end, they are separate things altogether. A class can implement both, but often enough, they are not both used. IF said class makes use of both interfaces, then you can freely cast an instance of that class to either. However, using both is incredibly redundant, as in the end, they do the same thing, with IItemHandler being the better choice, as it handles much of the logic for you. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
May 18, 20178 yr Author 2 minutes ago, Matryoshika said: No. IItemHandler, and IInventory are both interfaces, that both do similar things, but in the end, they are separate things altogether. A class can implement both, but often enough, they are not both used. IF said class makes use of both interfaces, then you can freely cast an instance of that class to either. However, using both is incredibly redundant, as in the end, they do the same thing, with IItemHandler being the better choice, as it handles much of the logic for you. I mean how to make it work wit Container#onCraftMatrixChanged, IContainerListener#sendAllWindowProperties. They only use IInventory
May 18, 20178 yr Author 4 minutes ago, diesieben07 said: No, IItemHandler and IInventory are separate interfaces. Why do you need those two methods? I mean how to make it work wit Container#onCraftMatrixChanged, IContainerListener#sendAllWindowProperties. They only use IInventory
May 18, 20178 yr Author Just now, diesieben07 said: Yes, I understand that. But why do you need these methods? onCraftMatrixChanged only calls detectAndSendChanges by default and sendAllWindowProperties only makes sense with something that natively implements IInventory. So what method will I use if I use IItemHandler to update the progress bar?
May 18, 20178 yr Author 4 minutes ago, diesieben07 said: You call sendProgressBarUpdate which will call updateProgressBar on the client. I have problem that the item insert/extract doesn't work. Each time I insert, the stack I insert doesn't decrease and when I extract, the stack doesn't take out. Here is my code: TileSolderingStation: https://pastebin.com/Xzw57H6S ItemHandlerBase: https://pastebin.com/bdgqDhka ItemHandlerPersistentCrafting: https://pastebin.com/fEbec0Mv
May 18, 20178 yr Author 2 minutes ago, diesieben07 said: Your pastebin links are private. Oops sorry, I have edited them
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.