Esempio n. 1
0
        void TryStart()
        {
            BlockPos    bp         = Pos.Copy().Offset(rmInputFace);
            BlockEntity checkblock = Api.World.BlockAccessor.GetBlockEntity(bp);

            deviceState = enDeviceState.MATERIALHOLD;
            if (Api.World is IServerWorldAccessor)
            {
                workingitem = null;
                var inputContainer = checkblock as BlockEntityContainer;
                if (inputContainer == null)
                {
                    return;
                }
                if (inputContainer.Inventory.Empty)
                {
                    return;
                }
                for (int c = 0; c < inputContainer.Inventory.Count; c++)
                {
                    ItemSlot checkslot = inputContainer.Inventory[c];
                    if (checkslot == null)
                    {
                        continue;
                    }
                    if (checkslot.StackSize == 0)
                    {
                        continue;
                    }

                    Item  checkitem   = checkslot.Itemstack.Item;
                    Block checkiblock = checkslot.Itemstack.Block;

                    if (checkitem == null && checkiblock == null)
                    {
                        continue;
                    }
                    CollectibleObject co;
                    if (checkitem != null)
                    {
                        co = checkitem as CollectibleObject;
                    }
                    else
                    {
                        co = checkiblock as CollectibleObject;
                    }

                    if (!MacerationRecipe.CanMacerate(co, Api, MachineName))
                    {
                        continue;
                    }
                    workingitem = co;
                    //Item has been set, need to pull one item from the stack
                    deviceState = enDeviceState.RUNNING;
                    checkslot.TakeOut(1);
                    checkslot.MarkDirty();
                    break;
                }
            }
        }