fCraft.Player.ProcessSetBlockPacket C# (CSharp) Method

ProcessSetBlockPacket() private method

private ProcessSetBlockPacket ( ) : void
return void
        private void ProcessSetBlockPacket()
        {
            BytesReceived += 9;
            if ( World == null || World.Map == null )
                return;
            ResetIdleTimer();
            short x = IPAddress.NetworkToHostOrder( reader.ReadInt16() );
            short z = IPAddress.NetworkToHostOrder( reader.ReadInt16() );
            short y = IPAddress.NetworkToHostOrder( reader.ReadInt16() );
            ClickAction action = ( reader.ReadByte() == 1 ) ? ClickAction.Build : ClickAction.Delete;
            byte type = reader.ReadByte();

            // if a player is using InDev or SurvivalTest client, they may try to
            // place blocks that are not found in MC Classic. Convert them!
            if ( type > 49 ) {
                type = MapDat.MapBlock( type );
            }

            Vector3I coords = new Vector3I( x, y, z );

            // If block is in bounds, count the click.
            // Sometimes MC allows clicking out of bounds,
            // like at map transitions or at the top layer of the world.
            // Those clicks should be simply ignored.
            if ( World.Map.InBounds( coords ) ) {
                var e = new PlayerClickingEventArgs( this, coords, action, ( Block )type );
                if ( RaisePlayerClickingEvent( e ) ) {
                    RevertBlockNow( coords );
                } else {
                    RaisePlayerClickedEvent( this, coords, e.Action, e.Block );
                    PlaceBlock( coords, e.Action, e.Block );
                }
            }
        }