fCraft.PlantPhysics.blockSquash C# (CSharp) Method

blockSquash() public static method

public static blockSquash ( object sender, PlayerPlacingBlockEventArgs e ) : void
sender object
e fCraft.Events.PlayerPlacingBlockEventArgs
return void
        public static void blockSquash( object sender, PlayerPlacingBlockEventArgs e )
        {
            try {
                Player player = e.Player;
                World world = player.World;
                if ( null == world )
                    return;
                lock ( world.SyncRoot ) {
                    if ( null != world.Map && world.IsLoaded && world.plantPhysics ) {
                        if ( e.NewBlock == Block.Plant ) {
                            world.AddPhysicsTask( new PlantTask( world, ( short )e.Coords.X, ( short )e.Coords.Y, ( short )e.Coords.Z ), PlantTask.GetRandomDelay() );
                        }
                        Vector3I z = new Vector3I( e.Coords.X, e.Coords.Y, e.Coords.Z - 1 );
                        if ( world.Map.GetBlock( z ) == Block.Grass && e.NewBlock != Block.Air ) {
                            world.Map.QueueUpdate( new BlockUpdate( null, z, Block.Dirt ) );
                        } else if ( Physics.CanSquash( world.Map.GetBlock( z ) ) && e.NewBlock != Block.Air ) {
                            e.Result = CanPlaceResult.Revert;
                            Player.RaisePlayerPlacedBlockEvent( player, world.Map, z, world.Map.GetBlock( z ), e.NewBlock, BlockChangeContext.Physics );
                            world.Map.QueueUpdate( new BlockUpdate( null, z, e.NewBlock ) );
                        }
                    }
                }
            } catch ( Exception ex ) {
                Logger.Log( LogType.SeriousError, "BlockSquash" + ex );
            }
        }
PlantPhysics