Use IItemHandler instead of IInventory internally (#2971)

* Use IItemHandler instead of IInventory internally
This commit is contained in:
fscan
2017-07-28 22:04:32 +02:00
committed by yueh
parent c077840988
commit 52d28fabe3
156 changed files with 2410 additions and 4604 deletions
@@ -22,8 +22,8 @@ package appeng.container.implementations;
import java.util.Iterator;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
@@ -41,6 +41,7 @@ import appeng.container.slot.SlotFakeTypeOnly;
import appeng.container.slot.SlotRestrictedInput;
import appeng.parts.misc.PartStorageBus;
import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.iterators.NullIterator;
@@ -73,7 +74,7 @@ public class ContainerStorageBus extends ContainerUpgradeable
final int xo = 8;
final int yo = 23 + 6;
final IInventory config = this.getUpgradeable().getInventoryByName( "config" );
final IItemHandler config = this.getUpgradeable().getInventoryByName( "config" );
for( int y = 0; y < 7; y++ )
{
for( int x = 0; x < 9; x++ )
@@ -89,7 +90,7 @@ public class ContainerStorageBus extends ContainerUpgradeable
}
}
final IInventory upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer() ) )
.setNotDraggable() );
this.addSlotToContainer(
@@ -143,17 +144,13 @@ public class ContainerStorageBus extends ContainerUpgradeable
public void clear()
{
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
for( int x = 0; x < inv.getSizeInventory(); x++ )
{
inv.setInventorySlotContents( x, ItemStack.EMPTY );
}
ItemHandlerUtil.clear( this.getUpgradeable().getInventoryByName( "config" ) );
this.detectAndSendChanges();
}
public void partition()
{
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
final IMEInventory<IAEItemStack> cellInv = this.storageBus.getInternalHandler();
@@ -164,17 +161,17 @@ public class ContainerStorageBus extends ContainerUpgradeable
i = list.iterator();
}
for( int x = 0; x < inv.getSizeInventory(); x++ )
for( int x = 0; x < inv.getSlots(); x++ )
{
if( i.hasNext() && this.isSlotEnabled( ( x / 9 ) - 2 ) )
{
final ItemStack g = i.next().getItemStack();
g.setCount( 1 );
inv.setInventorySlotContents( x, g );
ItemHandlerUtil.setStackInSlot( inv, x, g );
}
else
{
inv.setInventorySlotContents( x, ItemStack.EMPTY );
ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.EMPTY );
}
}