private static void appendUnknownMask(Player p, PacketBuilder updateBlock)
 {
     updateBlock.addByteC(1);
     updateBlock.addLEShort(65465);
     updateBlock.addByteA(21);
     updateBlock.addUShort(434454);
 }
        private static void appendForceMovement(Player p, PacketBuilder updateBlock)
        {
            Location      myLocation = p.getUpdateFlags().getLastRegion();
            ForceMovement fm         = p.getForceMovement();

            updateBlock.addByteC(fm.getX1());
            updateBlock.addByte((byte)(fm.getY1()));
            updateBlock.addByteA(fm.getX2());
            updateBlock.addByte((byte)fm.getY2());
            updateBlock.addLEShort(fm.getSpeed1());
            updateBlock.addLEShort(fm.getSpeed2());
            updateBlock.addByteC(fm.getDirection());
        }
        private static void appendHitUpdate(Player p, PacketBuilder updateBlock)
        {
            int ratio = (p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) * 255) / p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS);

            if (p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) > p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS))
            {
                ratio = (p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) * 255) / p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS);
            }

            if (p.getHits().getHitDamage1() < 128) //damage can be either addByte [for damage less then 128 otherwise UShort]
            {
                updateBlock.addByte((byte)p.getHits().getHitDamage1());
            }
            else
            {
                updateBlock.addUShort(p.getHits().getHitDamage1() + 0x8000);
            }
            updateBlock.addByteA((byte)p.getHits().getHitType1());
            updateBlock.addByteS(ratio);
        }
        private static void appendAppearanceUpdate(Player p, PacketBuilder updateBlock) {
		    PacketBuilder playerProps = new PacketBuilder().setSize(Packet.Size.Bare);
		
		    Appearance app = p.getAppearance();
		    playerProps.addByte((byte) (app.getGender() & 0xFF));
		    if((app.getGender() & 0x2) == 2) {
			    playerProps.addByte((byte) 0);
			    playerProps.addByte((byte) 0);
		    }
		    playerProps.addByte((byte) p.getPrayers().getPkIcon());
		    playerProps.addByte((byte) p.getPrayers().getHeadIcon());
		    if (!app.isInvisible()) {
			    if(!app.isNpc()) {
				    for(int i = 0; i < 4; i++) {
					    if(p.getEquipment().getItemInSlot((ItemData.EQUIP)i) != -1) {
                            playerProps.addUShort(32768 + p.getEquipment().getSlot((ItemData.EQUIP)i).getDefinition().getEquipId());
					    } else {
						    playerProps.addByte((byte) 0);
					    }
				    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.CHEST).getDefinition().getEquipId());
				    } else {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.AMULET));
				    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.SHIELD) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.SHIELD).getDefinition().getEquipId());
				    } else {
					    playerProps.addByte((byte) 0);
				    }
                    Item chest = p.getEquipment().getSlot(ItemData.EQUIP.CHEST);
                    if (chest != null && chest.getDefinition() != null)
                    {
					    if(!ItemData.isFullBody(chest.getDefinition())) {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.WEAPON));
					    } else {
						    playerProps.addByte((byte) 0);
					    }
				    } else {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.WEAPON));
				    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.LEGS).getDefinition().getEquipId());
				    } else {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.SHIELD));
				    }
                    Item hat = p.getEquipment().getSlot(ItemData.EQUIP.HAT);
                    if (hat != null && hat.getDefinition() != null)
                    {
					    if(!ItemData.isFullHat(hat.getDefinition()) && !ItemData.isFullMask(hat.getDefinition())) {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.HAT));
					    } else {
						    playerProps.addByte((byte) 0);
					    }
				    } else {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.HAT));
				    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.HANDS) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.HANDS).getDefinition().getEquipId());
				    } else {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CHEST));
				    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.FEET) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.FEET).getDefinition().getEquipId());
				    } else {
					    playerProps.addUShort(0x100 + app.getLook(6));
				    }
                    if (hat != null && hat.getDefinition() != null)
                    {
					    if(!ItemData.isFullMask(hat.getDefinition())) {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CAPE));
					    } else {
						    playerProps.addByte((byte) 0);
					    }
				    } else {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CAPE));
				    }
			    } else {
				    playerProps.addUShort(-1);
				    playerProps.addUShort(app.getNpcId());
				    playerProps.addByte((byte) 255);
			    }
		    } else {
			    for (int i = 0; i < 12; i++) {
				    playerProps.addByte((byte) 0);
			    }
		    }
		    foreach(int colour in app.getColoursArray()) {
			    playerProps.addByte((byte) colour);
		    }
		    playerProps.addUShort(p.getEquipment().getStandWalkAnimation());
		    playerProps.addLong(p.getLoginDetails().getLongName());
		    playerProps.addByte((byte) p.getSkills().getCombatLevel());
		    playerProps.addUShort(0);
		    playerProps.addByte((byte) 0);
		    updateBlock.addByteA((byte) (playerProps.getLength() & 0xFF));
		    updateBlock.addBytes(playerProps.toPacket().getData(), 0, playerProps.getLength());
	    }
        private static void appendHitUpdate(Player p, PacketBuilder updateBlock)
        {
            int ratio = (p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) * 255) / p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS);
            if (p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) > p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS))
                ratio = (p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) * 255) / p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS);

            if(p.getHits().getHitDamage1() < 128) //damage can be either addByte [for damage less then 128 otherwise UShort]
                updateBlock.addByte((byte)p.getHits().getHitDamage1()); 
            else
                updateBlock.addUShort(p.getHits().getHitDamage1() + 0x8000);
            updateBlock.addByteA((byte)p.getHits().getHitType1());
            updateBlock.addByteS(ratio);
        }
 private static void appendUnknownMask(Player p, PacketBuilder updateBlock)
 {
     updateBlock.addByteC(1);
     updateBlock.addLEShort(65465);
     updateBlock.addByteA(21);
     updateBlock.addUShort(434454);
 }
 private static void appendForceMovement(Player p, PacketBuilder updateBlock)
 {
     Location myLocation = p.getUpdateFlags().getLastRegion();
     ForceMovement fm = p.getForceMovement();
     updateBlock.addByteC(fm.getX1());
     updateBlock.addByte((byte)(fm.getY1()));
     updateBlock.addByteA(fm.getX2());
     updateBlock.addByte((byte)fm.getY2());
     updateBlock.addLEShort(fm.getSpeed1());
     updateBlock.addLEShort(fm.getSpeed2());
     updateBlock.addByteC(fm.getDirection());
 }
        private static void appendAppearanceUpdate(Player p, PacketBuilder updateBlock)
        {
            PacketBuilder playerProps = new PacketBuilder().setSize(Packet.Size.Bare);

            Appearance app = p.getAppearance();

            playerProps.addByte((byte)(app.getGender() & 0xFF));
            if ((app.getGender() & 0x2) == 2)
            {
                playerProps.addByte((byte)0);
                playerProps.addByte((byte)0);
            }
            playerProps.addByte((byte)p.getPrayers().getPkIcon());
            playerProps.addByte((byte)p.getPrayers().getHeadIcon());
            if (!app.isInvisible())
            {
                if (!app.isNpc())
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (p.getEquipment().getItemInSlot((ItemData.EQUIP)i) != -1)
                        {
                            playerProps.addUShort(32768 + p.getEquipment().getSlot((ItemData.EQUIP)i).getDefinition().getEquipId());
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.CHEST).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.AMULET));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.SHIELD) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.SHIELD).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addByte((byte)0);
                    }
                    Item chest = p.getEquipment().getSlot(ItemData.EQUIP.CHEST);
                    if (chest != null && chest.getDefinition() != null)
                    {
                        if (!ItemData.isFullBody(chest.getDefinition()))
                        {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.WEAPON));
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.WEAPON));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.LEGS).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.SHIELD));
                    }
                    Item hat = p.getEquipment().getSlot(ItemData.EQUIP.HAT);
                    if (hat != null && hat.getDefinition() != null)
                    {
                        if (!ItemData.isFullHat(hat.getDefinition()) && !ItemData.isFullMask(hat.getDefinition()))
                        {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.HAT));
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.HAT));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.HANDS) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.HANDS).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CHEST));
                    }
                    if (p.getEquipment().getItemInSlot(ItemData.EQUIP.FEET) != -1)
                    {
                        playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.FEET).getDefinition().getEquipId());
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(6));
                    }
                    if (hat != null && hat.getDefinition() != null)
                    {
                        if (!ItemData.isFullMask(hat.getDefinition()))
                        {
                            playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CAPE));
                        }
                        else
                        {
                            playerProps.addByte((byte)0);
                        }
                    }
                    else
                    {
                        playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CAPE));
                    }
                }
                else
                {
                    playerProps.addUShort(-1);
                    playerProps.addUShort(app.getNpcId());
                    playerProps.addByte((byte)255);
                }
            }
            else
            {
                for (int i = 0; i < 12; i++)
                {
                    playerProps.addByte((byte)0);
                }
            }
            foreach (int colour in app.getColoursArray())
            {
                playerProps.addByte((byte)colour);
            }
            playerProps.addUShort(p.getEquipment().getStandWalkAnimation());
            playerProps.addLong(p.getLoginDetails().getLongName());
            playerProps.addByte((byte)p.getSkills().getCombatLevel());
            playerProps.addUShort(0);
            playerProps.addByte((byte)0);
            updateBlock.addByteA((byte)(playerProps.getLength() & 0xFF));
            updateBlock.addBytes(playerProps.toPacket().getData(), 0, playerProps.getLength());
        }