Posted June 3, 20196 yr Code is at https://github.com/JGgithub2018/Simple-Batteries The machine is the BlockAlloyFurnace and related classes. What I'm trying to accomplish is a way to only allow players to interact with the slots. Hoppers shouldn't insert anywhere. I've created an ItemHandler that cannot be modified externally as well.
June 4, 20196 yr https://github.com/JGgithub2018/Simple-Batteries/blob/master/src/main/java/jgcodes/sb/forgecaps/ReadOnlyItemHandler.java ?? just implement IItemHandler your modID is to short use ¨simplebatteries¨ not sb Edited June 4, 20196 yr by loordgek
June 4, 20196 yr https://github.com/JGgithub2018/Simple-Batteries/blob/master/src/main/java/jgcodes/sb/forgecaps/ReadOnlyItemHandler.java#L23 A read-only stack handler should not allow a set. You want to set, keep a reference to the internal stack handler externally and set it there. 9 hours ago, loordgek said: https://github.com/JGgithub2018/Simple-Batteries/blob/master/src/main/java/jgcodes/sb/forgecaps/ReadOnlyItemHandler.java ?? just implement IItemHandler Extending ItemStackHandler is perfectly fine, especially when you don't want to deal with some of the implementations (such as read/write to NBT), as its more work than simply nullifying the behavior you don't want (such as preventing insertion and extraction). Edited June 4, 20196 yr by Draco18s 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.
June 4, 20196 yr 51 minutes ago, Draco18s said: Extending ItemStackHandler is perfectly fine, especially when you don't want to deal with some of the implementations (such as read/write to NBT), as its more work than simply nullifying the behavior you don't want (such as preventing insertion and extraction). look at what he is doing he is using a ItemStackHandler to wrap a ItemStackHandler
June 4, 20196 yr 1 hour ago, loordgek said: look at what he is doing he is using a ItemStackHandler to wrap a ItemStackHandler So? I did too: https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/api/internal/inventory/OutputItemStackHandler.java There's a very legitimate reason to do this. My OutputSlotHandler is exposed via GetCapability (so that machines can extract from the slot, but not insert) while the internalSlot is accessed directly by the machine in order to produce output. Creating a "read only" slot (one that can be queried for its contents, but not have the item extracted, nor allow an item insertion) would work the same way. The internal slot (the one that is being wrapped) can still be accessed normally in a private manner while the read only wrapper is exposed externally. 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.
June 6, 20196 yr On 6/5/2019 at 12:35 AM, Draco18s said: So? I did too: https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/api/internal/inventory/OutputItemStackHandler.java A little offtopic (sorry), but is there a particular reason you're calling markDirty() in getCapability()? Bearing in mind that markDirty() calls World#updateComparatorOutputLevel() which can do a potentially non-trivial amount of work (calling Block#onNeighborChange() on all your block's neighbors, and possibly even some of their neighbors too).
June 6, 20196 yr 47 minutes ago, desht said: A little offtopic (sorry), but is there a particular reason you're calling markDirty() in getCapability()? Bearing in mind that markDirty() calls World#updateComparatorOutputLevel() which can do a potentially non-trivial amount of work (calling Block#onNeighborChange() on all your block's neighbors, and possibly even some of their neighbors too). Probably left over from an issue where something wasn't saving. Its been like 2 years. 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.