File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
src/main/java/gregtech/api/capability/impl Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 11package gregtech .api .capability .impl ;
22
3+ import gregtech .api .capability .INotifiableHandler ;
4+ import gregtech .api .metatileentity .MetaTileEntity ;
5+
36import net .minecraft .item .ItemStack ;
47import net .minecraftforge .items .IItemHandler ;
58import net .minecraftforge .items .IItemHandlerModifiable ;
1518/**
1619 * Efficiently delegates calls into multiple item handlers
1720 */
18- public class ItemHandlerList extends AbstractList <IItemHandler > implements IItemHandlerModifiable {
21+ public class ItemHandlerList extends AbstractList <IItemHandler > implements IItemHandlerModifiable , INotifiableHandler {
1922
2023 protected final Int2ObjectMap <IItemHandler > handlerBySlotIndex = new Int2ObjectOpenHashMap <>();
2124 protected final Object2IntMap <IItemHandler > baseIndexOffset = new Object2IntArrayMap <>();
@@ -109,6 +112,24 @@ public Collection<IItemHandler> getBackingHandlers() {
109112 return Collections .unmodifiableCollection (baseIndexOffset .keySet ());
110113 }
111114
115+ @ Override
116+ public void addNotifiableMetaTileEntity (MetaTileEntity metaTileEntity ) {
117+ for (IItemHandler handler : this ) {
118+ if (handler instanceof INotifiableHandler notifiableHandler ) {
119+ notifiableHandler .addNotifiableMetaTileEntity (metaTileEntity );
120+ }
121+ }
122+ }
123+
124+ @ Override
125+ public void removeNotifiableMetaTileEntity (MetaTileEntity metaTileEntity ) {
126+ for (IItemHandler handler : this ) {
127+ if (handler instanceof INotifiableHandler notifiableHandler ) {
128+ notifiableHandler .removeNotifiableMetaTileEntity (metaTileEntity );
129+ }
130+ }
131+ }
132+
112133 @ Override
113134 public int size () {
114135 return baseIndexOffset .size ();
You can’t perform that action at this time.
0 commit comments