Generic ICellInventoryHandler (#3624)

Allows addons who register a custom IStorageChannel to use the IStorageCell interface without registering a cell handler. Also adds some helpers (poweredInsert/poweredExtract).
This breaks API!
This commit is contained in:
fscan
2018-07-22 19:20:47 +02:00
committed by GitHub
parent 85dec35366
commit c1c7e94cf6
41 changed files with 630 additions and 842 deletions
@@ -4,6 +4,7 @@ package appeng.tile.inventory;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.IInternalItemHandler;
@@ -102,7 +103,11 @@ public class AppEngCellInventory implements IInternalItemHandler
{
if( this.handlerForSlot[slot] != null )
{
this.handlerForSlot[slot].getCellInv().persist();
final ICellInventory ci = this.handlerForSlot[slot].getCellInv();
if( ci != null )
{
ci.persist();
}
}
}
@@ -110,7 +115,9 @@ public class AppEngCellInventory implements IInternalItemHandler
{
if( this.handlerForSlot[slot] != null )
{
if( this.handlerForSlot[slot].getCellInv().getItemStack() != this.inv.getStackInSlot( slot ) )
final ICellInventory ci = this.handlerForSlot[slot].getCellInv();
if( ci == null || ci.getItemStack() != this.inv.getStackInSlot( slot ) )
{
this.handlerForSlot[slot] = null;
}