Exemple #1
0
        private void RefillSlotIfEmpty(ItemSlot slot, EntityAgent byEntity)
        {
            if (!slot.Empty)
            {
                return;
            }

            byEntity.WalkInventory((invslot) =>
            {
                if (invslot is ItemSlotCreative)
                {
                    return(true);
                }

                InventoryBase inv = invslot.Inventory;
                if (!(inv is InventoryBasePlayer) && !inv.HasOpened((byEntity as EntityPlayer).Player))
                {
                    return(true);
                }

                if (invslot.Itemstack != null && invslot.Itemstack.Collectible is ItemSpear)
                {
                    invslot.TryPutInto(byEntity.World, slot);
                    invslot.Inventory.PerformNotifySlot(invslot.Inventory.GetSlotId(invslot));
                    slot.Inventory.PerformNotifySlot(slot.Inventory.GetSlotId(slot));

                    return(false);
                }

                return(true);
            });
        }