private void PutAppearanceBlock(AppearanceBlock block, MessageFrameBuilder builder)
        {
            Appearance appearance       = block.Appearance;
            var        playerProperties = new MessageFrameBuilder(builder.Alloc);

            playerProperties.Put(MessageType.Byte, (int)appearance.Gender);
            playerProperties.Put(MessageType.Byte, 0);
            playerProperties.Put(MessageType.Byte, 0);

            if (block.NpcId > 0)
            {
                playerProperties.Put(MessageType.Byte, 255);
                playerProperties.Put(MessageType.Byte, 255);
                playerProperties.Put(MessageType.Short, block.NpcId);
            }
            else
            {
                //Inventory equipment = block.getEquipment();
                int[] style = appearance.Style;
                //Item item, chest, helm;

                for (int slot = 0; slot < 4; slot++)
                {
                    playerProperties.Put(MessageType.Byte, 0);
                }

                playerProperties.Put(MessageType.Short, 0x100 + style[2]); //Chest
                playerProperties.Put(MessageType.Byte, 0);                 //Shield
                playerProperties.Put(MessageType.Short, 0x100 + style[3]); //Arms
                playerProperties.Put(MessageType.Short, 0x100 + style[5]); //Legs
                playerProperties.Put(MessageType.Short, 0x100 + style[0]); //Helm
                playerProperties.Put(MessageType.Short, 0x100 + style[4]); //Hands
                playerProperties.Put(MessageType.Short, 0x100 + style[6]); //Feet
                playerProperties.Put(MessageType.Short, 0x100 + style[1]); //Beard
            }

            int[] colors = appearance.Colors;
            foreach (int color in colors)
            {
                playerProperties.Put(MessageType.Byte, color);
            }

            playerProperties.Put(MessageType.Short, 0x328); // stand
            playerProperties.Put(MessageType.Short, 0x337); // stand turn
            playerProperties.Put(MessageType.Short, 0x333); // walk
            playerProperties.Put(MessageType.Short, 0x334); // turn 180
            playerProperties.Put(MessageType.Short, 0x335); // turn 90 cw
            playerProperties.Put(MessageType.Short, 0x336); // turn 90 ccw
            playerProperties.Put(MessageType.Short, 0x338); // run

            playerProperties.Put(MessageType.Long, block.Name);
            playerProperties.Put(MessageType.Byte, block.Combat);
            playerProperties.Put(MessageType.Short, block.Skill);

            builder.Put(MessageType.Byte, DataTransformation.Add, playerProperties.GetLength());
            builder.PutRawBuilder(playerProperties);
        }
        public MessageFrame ToMessage(IByteBufferAllocator alloc)
        {
            var bldr = new MessageFrameBuilder(alloc, 150, FrameType.VariableShort);

            bldr.SwitchToBitAccess();

            var blockBuilder = new MessageFrameBuilder(alloc);

            PutMovementUpdate(Segment, bldr);
            PutBlocks(Segment, blockBuilder);
            bldr.PutBits(8, LocalPlayers);

            foreach (SynchronizationSegment segment in Segments)
            {
                SegmentType type = segment.Type;
                if (type == SegmentType.Remove_Mob)
                {
                    PutRemovePlayerUpdate(bldr);
                }
                else if (type == SegmentType.Add_Mob)
                {
                    PutAddPlayerUpdate((AddPlayerSegment)segment, bldr);
                    PutBlocks(segment, blockBuilder);
                }
                else
                {
                    PutMovementUpdate(segment, bldr);
                    PutBlocks(segment, blockBuilder);
                }
            }

            if (blockBuilder.GetLength() > 0)
            {
                bldr.PutBits(11, 2047);
                bldr.SwitchToByteAccess();
                bldr.PutRawBuilder(blockBuilder);
            }
            else
            {
                bldr.SwitchToByteAccess();
            }

            return(bldr.ToMessageFrame());
        }