Switch to new IItemHandler (#3669)

This commit is contained in:
fscan
2018-10-04 20:39:06 +02:00
committed by yueh
parent e21c59b326
commit d88f550eb0
14 changed files with 34 additions and 158 deletions
@@ -25,12 +25,13 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.EmptyHandler;
import appeng.util.helpers.ItemHandlerUtil;
public class WrapperChainedItemHandler implements IInternalItemHandler
public class WrapperChainedItemHandler implements IItemHandlerModifiable
{
private IItemHandler[] itemHandler; // the handlers
private int[] baseIndex; // index-offsets of the different handlers
@@ -159,20 +160,11 @@ public class WrapperChainedItemHandler implements IInternalItemHandler
}
@Override
public boolean isItemValidForSlot( int slot, ItemStack stack )
public boolean isItemValid( int slot, ItemStack stack )
{
int index = this.getIndexForSlot( slot );
IItemHandler handler = this.getHandlerFromIndex( index );
int targetSlot = this.getSlotFromIndex( slot, index );
return ItemHandlerUtil.isItemValidForSlot( handler, targetSlot, stack );
}
@Override
public void markDirty( int slot )
{
int index = this.getIndexForSlot( slot );
IItemHandler handler = this.getHandlerFromIndex( index );
int targetSlot = this.getSlotFromIndex( slot, index );
ItemHandlerUtil.markDirty( handler, targetSlot );
return handler.isItemValid( targetSlot, stack );
}
}