Use IItemHandler instead of IInventory internally (#2971)
* Use IItemHandler instead of IInventory internally
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user