public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel)
        {
            int stockMod = 1;

            if (byPlayer.Entity.Controls.Sprint)
            {
                stockMod = byPlayer.InventoryManager.ActiveHotbarSlot.MaxSlotStackSize;
            }

            BlockEntity     be   = world.BlockAccessor.GetBlockEntity(blockSel.Position);
            RubbleStorageBE rcbe = world.BlockAccessor.GetBlockEntity(blockSel.Position) as RubbleStorageBE;

            if (be is GenericStorageCapBE)
            {
                rcbe = world.BlockAccessor.GetBlockEntity((be as GenericStorageCapBE).core) as RubbleStorageBE;
            }
            if (rcbe == null)
            {
                return(true);
            }

            // if the player is looking at one of the buttons on the crate.
            if (blockSel.SelectionBoxIndex == 1 && byPlayer.Entity.Controls.Sneak)
            {
                setLock(rcbe, RubbleStorageBE.StorageLocksEnum.Sand);
            }
            else if (blockSel.SelectionBoxIndex == 2 && byPlayer.Entity.Controls.Sneak)
            {
                setLock(rcbe, RubbleStorageBE.StorageLocksEnum.Gravel);
            }
            else if (blockSel.SelectionBoxIndex == 3 && byPlayer.Entity.Controls.Sneak)
            {
                setLock(rcbe, RubbleStorageBE.StorageLocksEnum.Stone);
            }

            if (blockSel.SelectionBoxIndex == 1)
            {
                if (rcbe.RemoveResource(world, byPlayer, blockSel, "sand", stockMod))
                {
                    if (world.Side == EnumAppSide.Client)
                    {
                        (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack);
                    }
                    world.PlaySoundAt(new AssetLocation("game", "sounds/effect/stonecrush"), byPlayer, byPlayer);
                    interactParticles.MinPos       = blockSel.Position.ToVec3d() + blockSel.HitPosition;
                    interactParticles.ColorByBlock = world.BlockAccessor.GetBlock(blockSel.Position);
                    world.SpawnParticles(interactParticles, byPlayer);
                }
            }
            else if (blockSel.SelectionBoxIndex == 2)
            {
                if (rcbe.RemoveResource(world, byPlayer, blockSel, "gravel", stockMod))
                {
                    if (world.Side == EnumAppSide.Client)
                    {
                        (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack);
                    }
                    world.PlaySoundAt(new AssetLocation("game", "sounds/effect/stonecrush"), byPlayer, byPlayer);
                    interactParticles.MinPos       = blockSel.Position.ToVec3d() + blockSel.HitPosition;
                    interactParticles.ColorByBlock = world.BlockAccessor.GetBlock(blockSel.Position);
                    world.SpawnParticles(interactParticles, byPlayer);
                }
            }
            else if (blockSel.SelectionBoxIndex == 3)
            {
                if (rcbe.RemoveResource(world, byPlayer, blockSel, "stone", stockMod))
                {
                    if (world.Side == EnumAppSide.Client)
                    {
                        (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack);
                    }
                    world.PlaySoundAt(new AssetLocation("game", "sounds/effect/stonecrush"), byPlayer, byPlayer);
                    interactParticles.MinPos       = blockSel.Position.ToVec3d() + blockSel.HitPosition;
                    interactParticles.ColorByBlock = world.BlockAccessor.GetBlock(blockSel.Position);
                    world.SpawnParticles(interactParticles, byPlayer);
                }
            }

            else if (blockSel.SelectionBoxIndex == 0 && byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack != null)
            {
                // attempts to add the players resource to the block.
                if (byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.ItemAttributes["rubbleable"].AsBool())
                {
                    if (rcbe.Degrade())
                    {
                        if (world.Side == EnumAppSide.Client)
                        {
                            (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack);
                        }
                        world.PlaySoundAt(new AssetLocation("game", "sounds/block/heavyice"), byPlayer, byPlayer);
                    }
                }
                else if (byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.Attributes.GetTreeAttribute("contents") != null &&
                         byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.Attributes.GetTreeAttribute("contents").GetItemstack("0") != null)
                {
                    ItemStack tstack = byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.Attributes.GetTreeAttribute("contents").GetItemstack("0");
                    if (tstack.Collectible.Code.Domain == "game" && tstack.Collectible.Code.Path == "waterportion")
                    {
                        if (rcbe.Drench(world, blockSel))
                        {
                            if (world.Side == EnumAppSide.Client)
                            {
                                (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack);
                            }
                            world.PlaySoundAt(new AssetLocation("game", "sounds/environment/largesplash1"), byPlayer, byPlayer);
                        }
                    }
                }
                else
                {
                    if (rcbe.AddResource(byPlayer.InventoryManager.ActiveHotbarSlot, stockMod))
                    {
                        if (world.Side == EnumAppSide.Client)
                        {
                            (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack);
                        }
                        world.PlaySoundAt(new AssetLocation("game", "sounds/effect/stonecrush"), byPlayer, byPlayer);
                    }
                }
            }
            else if (blockSel.SelectionBoxIndex == 0 && byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack == null)
            {
                // if the players hand is empty we want to take all the matching blocks outs of their inventory.
                if (rcbe.AddAll(byPlayer))
                {
                    if (world.Side == EnumAppSide.Client)
                    {
                        (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack);
                    }
                    world.PlaySoundAt(new AssetLocation("game", "sounds/effect/stonecrush"), byPlayer, byPlayer);
                }
            }
            rcbe.CheckDisplayVariant(world, blockSel);

            return(true);
        }