fCraft.Session.ProcessSetBlockPacket C# (CSharp) Method

ProcessSetBlockPacket() public method

public ProcessSetBlockPacket ( ) : void
return void
        void ProcessSetBlockPacket() {
            bytesReceived += 9;
            if( Player.World == null || Player.World.Map == null ) return;
            Player.ResetIdleTimer();
            short x = IPAddress.NetworkToHostOrder( reader.ReadInt16() );
            short h = IPAddress.NetworkToHostOrder( reader.ReadInt16() );
            short y = IPAddress.NetworkToHostOrder( reader.ReadInt16() );
            bool mode = (reader.ReadByte() == 1);
            byte type = reader.ReadByte();

            if( type > 49 ) {
                type = MapDat.MapBlock( type );
            }

            if( Player.World.Map.InBounds( x, y, h ) ) {
                var e = new PlayerClickingEventArgs( Player, x, y, h, mode, (Block)type );
                if( Server.RaisePlayerClickingEvent( e ) ) {
                    Player.RevertBlockNow( x, y, h );
                } else {
                    Server.RaisePlayerClickedEvent( Player, x, y, h, e.Mode, e.Block );
                    Player.PlaceBlock( x, y, h, e.Mode, e.Block );
                }
            }
        }