TileEntity tile = par3World.getTileEntity(par4, par5, par6);
if (tile != null && tile instanceof IInventory) {
IInventory inv = (IInventory) tile;
int[] slots = inv instanceof ISidedInventory ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(par7) : TileTransvectorInterface.buildSlotsForLinearInventory(inv);
for (int slot : slots) {
ItemStack stackInSlot = inv.getStackInSlot(slot);
if (stackInSlot == null) {
ItemStack stack = new ItemStack(bBlock, 1, bmeta);
int maxSize = stack.getMaxStackSize();
stack.stackSize = remove(par1ItemStack, maxSize);
if (stack.stackSize != 0) {
if (inv.isItemValidForSlot(slot, stack) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stack, par7))) {
inv.setInventorySlotContents(slot, stack);
inv.markDirty();
set = true;
}
}
} else if (stackInSlot.getItem() == Item.getItemFromBlock(bBlock) && stackInSlot.getItemDamage() == bmeta) {
int maxSize = stackInSlot.getMaxStackSize();
int missing = maxSize - stackInSlot.stackSize;
if (inv.isItemValidForSlot(slot, stackInSlot) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stackInSlot, par7))) {
stackInSlot.stackSize += remove(par1ItemStack, missing);
inv.markDirty();
set = true;
}
}
}
} else {
int remove = remove(par1ItemStack, 1);
if (remove > 0) {
Item.getItemFromBlock(bBlock).onItemUse(new ItemStack(bBlock, 1, bmeta), par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
set = true;
}
}
}