private void TakeBlock(object obj)
    {
        global::World world = global::GameManager.Instance.World;

        object[]                  array             = (object[])obj;
        int                       clrIdx            = (int)array[0];
        global::BlockValue        blockValue        = (global::BlockValue)array[1];
        global::Vector3i          vector3i          = (global::Vector3i)array[2];
        global::BlockValue        block             = world.GetBlock(vector3i);
        global::EntityPlayerLocal entityPlayerLocal = array[3] as global::EntityPlayerLocal;

        if (block.damage > 0)
        {
            global::GameManager.ShowTooltipWithAlert(entityPlayerLocal, global::Localization.Get("ttRepairBeforePickup", string.Empty), "ui_denied");
            return;
        }
        if (block.type != blockValue.type)
        {
            global::GameManager.ShowTooltipWithAlert(entityPlayerLocal, global::Localization.Get("ttBlockMissingPickup", string.Empty), "ui_denied");
            return;
        }
        global::TileEntityPowered tileEntityPowered = world.GetTileEntity(clrIdx, vector3i) as global::TileEntityPowered;

        if (tileEntityPowered != null && tileEntityPowered.IsUserAccessing())
        {
            global::GameManager.ShowTooltipWithAlert(entityPlayerLocal, global::Localization.Get("ttCantPickupInUse", string.Empty), "ui_denied");
            return;
        }

        // Remove TileEntity and wire
        base.OnBlockRemoved(world, (Chunk)world.GetChunkFromWorldPos(vector3i), vector3i, blockValue);

        global::LocalPlayerUI uiforPlayer = global::LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);

        this.HandleTakeInternalItems(tileEntityPowered, uiforPlayer);
        global::ItemStack itemStack = new global::ItemStack(block.ToItemValue(), 1);

        if (!uiforPlayer.xui.PlayerInventory.AddItem(itemStack, true))
        {
            uiforPlayer.xui.PlayerInventory.DropItem(itemStack);
        }

        world.SetBlockRPC(clrIdx, vector3i, global::BlockValue.Air);
    }
    public override bool OnBlockActivated(int _indexInBlockActivationCommands, global::WorldBase _world, int _cIdx, global::Vector3i _blockPos, global::BlockValue _blockValue, global::EntityAlive _player)
    {
        global::BlockValue block = _world.GetBlock(_blockPos.x, _blockPos.y - 1, _blockPos.z);

        if (global::Block.list[block.type].HasTag(global::BlockTags.Door))
        {
            _blockPos = new global::Vector3i(_blockPos.x, _blockPos.y - 1, _blockPos.z);
            return(this.OnBlockActivated(_indexInBlockActivationCommands, _world, _cIdx, _blockPos, _blockValue, _player));
        }
        global::TileEntityVendingMachine tileEntityVendingMachine = _world.GetTileEntity(_cIdx, _blockPos) as global::TileEntityVendingMachine;

        if (tileEntityVendingMachine == null)
        {
            return(false);
        }
        global::LocalPlayerUI uiforPlayer = global::LocalPlayerUI.GetUIForPlayer(_player as global::EntityPlayerLocal);

        if (null != uiforPlayer)
        {
            switch (_indexInBlockActivationCommands)
            {
            case 0:
                return(this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player));

            case 1:
            {
                this.tmpPickupUiforPlayer = uiforPlayer;
                this.tmpPickupClrIdx      = _cIdx;
                this.tmpPickupBlockPos    = _blockPos;
                this.tmpPickupItemStack   = new global::ItemStack(_blockValue.ToItemValue(), 1);
                this.TakeItemWithTimer(_cIdx, _blockPos, _blockValue, _player);
                return(true);
            }

            case 2:
                uiforPlayer.windowManager.Open(global::GUIWindowKeypad.ID, true, false, true);
                global::NGuiKeypad.Instance.LockedItem = tileEntityVendingMachine;
                return(true);
            }
        }
        return(false);
    }
    public void TakeItemWithTimer(int _cIdx, global::Vector3i _blockPos, global::BlockValue _blockValue, global::EntityAlive _player)
    {
        if (_blockValue.damage > 0)
        {
            global::GameManager.ShowTooltipWithAlert(_player as global::EntityPlayerLocal, global::Localization.Get("ttRepairBeforePickup", string.Empty), "ui_denied");
            return;
        }
        global::LocalPlayerUI playerUI = (_player as global::EntityPlayerLocal).PlayerUI;

        playerUI.windowManager.Open("timer", true, false, true);
        global::XUiC_Timer     xuiC_Timer     = (global::XUiC_Timer)playerUI.xui.GetChildByType <global::XUiC_Timer>();
        global::TimerEventData timerEventData = new global::TimerEventData();

        timerEventData.Data = new object[]
        {
            _cIdx,
            _blockValue,
            _blockPos,
            _player
        };
        timerEventData.Event += this.TakeBlock;
        xuiC_Timer.SetTimer(this.TakeDelay, timerEventData);
    }