public static byte[] spawnPlayerMapobject(MapleCharacter chr) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.SPAWN_PLAYER.getValue());
        mplew.writeInt(chr.getId());
        mplew.write(chr.getLevel());
        mplew.writeMapleAsciiString(chr.getName());
        MapleQuestStatus ultExplorer = chr.getQuestNoAdd(MapleQuest.getInstance(111111));
        if ((ultExplorer != null) && (ultExplorer.getCustomData() != null)) {
            mplew.writeMapleAsciiString(ultExplorer.getCustomData());
        } else {
            mplew.writeMapleAsciiString("");
        }
        if (chr.getGuildId() <= 0) {
            mplew.writeZeroBytes(12);//was8
        } else {
            MapleGuild gs = World.Guild.getGuild(chr.getGuildId());
            if (gs != null) {
                mplew.writeMapleAsciiString(gs.getName());
                mplew.writeShort(gs.getLogoBG());
                mplew.write(gs.getLogoBGColor());
                mplew.writeShort(gs.getLogo());
                mplew.write(gs.getLogoColor());
            } else {
                mplew.writeZeroBytes(8);
            }
        }
        mplew.write(0);
        
        final List<Pair<Integer, Integer>> buffvalue = new ArrayList<>();
        final List<Pair<Integer, Integer>> buffvaluenew = new ArrayList<>();
        int[] mask = new int[GameConstants.MAX_BUFFSTAT];
        mask[0] |= -33554432; //-0x2000000
        mask[2] |= 0x2000;
        mask[2] |= 0x1000;
        mask[6] |= 0x20000;
        mask[6] |= 0x8000;
        if ((chr.getBuffedValue(MapleBuffStat.DARKSIGHT) != null) || (chr.isHidden())) {
            mask[MapleBuffStat.DARKSIGHT.getPosition(true)] |= MapleBuffStat.DARKSIGHT.getValue();
        }
        if (chr.getBuffedValue(MapleBuffStat.SOULARROW) != null) {
            mask[MapleBuffStat.SOULARROW.getPosition(true)] |= MapleBuffStat.SOULARROW.getValue();
        }
        if (chr.getBuffedValue(MapleBuffStat.DAMAGE_ABSORBED) != null) {
            mask[MapleBuffStat.DAMAGE_ABSORBED.getPosition(true)] |= MapleBuffStat.DAMAGE_ABSORBED.getValue();
            buffvaluenew.add(new Pair(1000, 2));
            buffvaluenew.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.DAMAGE_ABSORBED), 4));
            buffvaluenew.add(new Pair(9, 0));
        }
        if (chr.getBuffedValue(MapleBuffStat.TEMPEST_BLADES) != null) {
            mask[MapleBuffStat.TEMPEST_BLADES.getPosition(true)] |= MapleBuffStat.TEMPEST_BLADES.getValue();
            buffvaluenew.add(new Pair(chr.getTotalSkillLevel(chr.getTrueBuffSource(MapleBuffStat.TEMPEST_BLADES)), 2));
            buffvaluenew.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.TEMPEST_BLADES), 4));
            buffvaluenew.add(new Pair(5, 0));
            buffvaluenew.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.TEMPEST_BLADES) == 61101002 ? 1 : 2, 4));
            buffvaluenew.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.TEMPEST_BLADES) == 61101002 ? 3 : 5, 4));
            buffvaluenew.add(new Pair(chr.getBuffedValue(MapleBuffStat.TEMPEST_BLADES), 4));
            buffvaluenew.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.TEMPEST_BLADES) == 61101002 ? 3 : 5, 4));
            if (chr.getTrueBuffSource(MapleBuffStat.TEMPEST_BLADES) != 61101002) {
                buffvaluenew.add(new Pair(8, 0));
            }
        }
        if ((chr.getBuffedValue(MapleBuffStat.COMBO) != null) && (chr.getBuffedValue(MapleBuffStat.TEMPEST_BLADES) == null)) {
            mask[MapleBuffStat.COMBO.getPosition(true)] |= MapleBuffStat.COMBO.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.COMBO), 1));
        }
        if (chr.getBuffedValue(MapleBuffStat.WK_CHARGE) != null) {
            mask[MapleBuffStat.WK_CHARGE.getPosition(true)] |= MapleBuffStat.WK_CHARGE.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.WK_CHARGE), 2));
            buffvalue.add(new Pair(chr.getBuffSource(MapleBuffStat.WK_CHARGE), 3));
        }
        if ((chr.getBuffedValue(MapleBuffStat.SHADOWPARTNER) != null) && (chr.getBuffedValue(MapleBuffStat.TEMPEST_BLADES) == null)) {
            mask[MapleBuffStat.SHADOWPARTNER.getPosition(true)] |= MapleBuffStat.SHADOWPARTNER.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.SHADOWPARTNER), 2));
            buffvalue.add(new Pair(chr.getBuffSource(MapleBuffStat.SHADOWPARTNER), 3));
        }
        
        if ((chr.getBuffedValue(MapleBuffStat.MORPH) != null) && (chr.getBuffedValue(MapleBuffStat.TEMPEST_BLADES) == null)) {//TODO
            mask[MapleBuffStat.MORPH.getPosition(true)] |= MapleBuffStat.MORPH.getValue();
            buffvalue.add(new Pair(chr.getStatForBuff(MapleBuffStat.MORPH).getMorph(chr), 2));
            buffvalue.add(new Pair(chr.getBuffSource(MapleBuffStat.MORPH), 3));
        }
        if (chr.getBuffedValue(MapleBuffStat.BERSERK_FURY) != null) {//works
            mask[MapleBuffStat.BERSERK_FURY.getPosition(true)] |= MapleBuffStat.BERSERK_FURY.getValue();
        }
        if (chr.getBuffedValue(MapleBuffStat.DIVINE_BODY) != null) {
            mask[MapleBuffStat.DIVINE_BODY.getPosition(true)] |= MapleBuffStat.DIVINE_BODY.getValue();
        }
        
        if (chr.getBuffedValue(MapleBuffStat.WIND_WALK) != null) {//TODO better
            mask[MapleBuffStat.WIND_WALK.getPosition(true)] |= MapleBuffStat.WIND_WALK.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.WIND_WALK), 2));
            buffvalue.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.WIND_WALK), 3));
        }
        if (chr.getBuffedValue(MapleBuffStat.PYRAMID_PQ) != null) {//TODO
            mask[MapleBuffStat.PYRAMID_PQ.getPosition(true)] |= MapleBuffStat.PYRAMID_PQ.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.PYRAMID_PQ), 2));
            buffvalue.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.PYRAMID_PQ), 3));
        }
        if (chr.getBuffedValue(MapleBuffStat.SOARING) != null) {//TODO
            mask[MapleBuffStat.SOARING.getPosition(true)] |= MapleBuffStat.SOARING.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.SOARING), 1));
        }
//        if (chr.getBuffedValue(MapleBuffStat.OWL_SPIRIT) != null) {//TODO
//            mask[MapleBuffStat.OWL_SPIRIT.getPosition(true)] |= MapleBuffStat.OWL_SPIRIT.getValue();
//            buffvalue.add(new Pair(Integer.valueOf(chr.getBuffedValue(MapleBuffStat.OWL_SPIRIT).intValue()), Integer.valueOf(2)));
//            buffvalue.add(new Pair(Integer.valueOf(chr.getTrueBuffSource(MapleBuffStat.OWL_SPIRIT)), Integer.valueOf(3)));
//        }
        if (chr.getBuffedValue(MapleBuffStat.FINAL_CUT) != null) {
            mask[MapleBuffStat.FINAL_CUT.getPosition(true)] |= MapleBuffStat.FINAL_CUT.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.FINAL_CUT), 2));
            buffvalue.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.FINAL_CUT), 3));
        }     
        if (chr.getBuffedValue(MapleBuffStat.TORNADO) != null) {
            mask[MapleBuffStat.TORNADO.getPosition(true)] |= MapleBuffStat.TORNADO.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.TORNADO), 2));
            buffvalue.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.TORNADO), 3));
        }
        if (chr.getBuffedValue(MapleBuffStat.INFILTRATE) != null) {
            mask[MapleBuffStat.INFILTRATE.getPosition(true)] |= MapleBuffStat.INFILTRATE.getValue();
        }
        if (chr.getBuffedValue(MapleBuffStat.MECH_CHANGE) != null) {
            mask[MapleBuffStat.MECH_CHANGE.getPosition(true)] |= MapleBuffStat.MECH_CHANGE.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.MECH_CHANGE), 2));
            buffvalue.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.MECH_CHANGE), 3));
        }
        if (chr.getBuffedValue(MapleBuffStat.DARK_AURA) != null) {
            mask[MapleBuffStat.DARK_AURA.getPosition(true)] |= MapleBuffStat.DARK_AURA.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.DARK_AURA), 2));
            buffvalue.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.DARK_AURA), 3));
        }
        if (chr.getBuffedValue(MapleBuffStat.BLUE_AURA) != null) {
            mask[MapleBuffStat.BLUE_AURA.getPosition(true)] |= MapleBuffStat.BLUE_AURA.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.BLUE_AURA), 2));
            buffvalue.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.BLUE_AURA), 3));
        }
        if (chr.getBuffedValue(MapleBuffStat.YELLOW_AURA) != null) {
            mask[MapleBuffStat.YELLOW_AURA.getPosition(true)] |= MapleBuffStat.YELLOW_AURA.getValue();
            buffvalue.add(new Pair(chr.getBuffedValue(MapleBuffStat.YELLOW_AURA), 2));
            buffvalue.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.YELLOW_AURA), 3));
        }
        if ((chr.getBuffedValue(MapleBuffStat.WATER_SHIELD) != null) && (chr.getBuffedValue(MapleBuffStat.TEMPEST_BLADES) == null)) {
            mask[MapleBuffStat.WATER_SHIELD.getPosition(true)] |= MapleBuffStat.WATER_SHIELD.getValue();
            buffvaluenew.add(new Pair(chr.getTotalSkillLevel(chr.getTrueBuffSource(MapleBuffStat.WATER_SHIELD)), 2));
            buffvaluenew.add(new Pair(chr.getTrueBuffSource(MapleBuffStat.WATER_SHIELD), 4));
            buffvaluenew.add(new Pair(9, 0));
        }

        for (int i = 0; i < mask.length; i++) {
            mplew.writeInt(mask[i]);
        }
        
        for (Pair i : buffvalue) {
            if (((Integer) i.right) == 3) {
                mplew.writeInt(((Integer) i.left));
            } else if (((Integer) i.right) == 2) {
                mplew.writeShort(((Integer) i.left).shortValue());
            } else if (((Integer) i.right) == 1) {
                mplew.write(((Integer) i.left).byteValue());
            }
        }

        mplew.writeInt(-1);
        if (buffvaluenew.isEmpty()) {
            mplew.writeZeroBytes(10);
        } else {
            mplew.write(0);
            for (Pair i : buffvaluenew) {
                if (((Integer) i.right) == 4) {
                    mplew.writeInt(((Integer) i.left));
                } else if (((Integer) i.right) == 2) {
                    mplew.writeShort(((Integer) i.left).shortValue());
                } else if (((Integer) i.right) == 1) {
                    mplew.write(((Integer) i.left).byteValue());
                } else if (((Integer) i.right) == 0) {
                    mplew.writeZeroBytes(((Integer) i.left));
                }
            }
        }
        mplew.writeZeroBytes(36);//v148

        int CHAR_MAGIC_SPAWN = Randomizer.nextInt();
        mplew.write(1);//
        mplew.writeInt(CHAR_MAGIC_SPAWN);//
        mplew.writeZeroBytes(8);//
        mplew.write(1);//
        mplew.writeInt(CHAR_MAGIC_SPAWN);//
        mplew.writeZeroBytes(10);//
        mplew.write(1);//
        mplew.writeInt(CHAR_MAGIC_SPAWN);//
        mplew.writeShort(0);
        int buffSrc = chr.getBuffSource(MapleBuffStat.MONSTER_RIDING);
        if (buffSrc > 0) {
            Item c_mount = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -118);
            Item mount = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -18);
            if ((GameConstants.getMountItem(buffSrc, chr) == 0) && (c_mount != null) && (chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -119) != null)) {
                mplew.writeInt(c_mount.getItemId());
            } else if ((GameConstants.getMountItem(buffSrc, chr) == 0) && (mount != null) && (chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -19) != null)) {
                mplew.writeInt(mount.getItemId());
            } else {
                mplew.writeInt(GameConstants.getMountItem(buffSrc, chr));
            }
            mplew.writeInt(buffSrc);
        } else {
            mplew.writeLong(0L);//
        }
        mplew.write(1);
        mplew.writeInt(CHAR_MAGIC_SPAWN);
        mplew.writeLong(0L);
        mplew.write(1);
        mplew.writeInt(CHAR_MAGIC_SPAWN);
        mplew.writeZeroBytes(15);
        mplew.write(1);
        mplew.writeInt(CHAR_MAGIC_SPAWN);
        mplew.writeZeroBytes(16);
        mplew.write(1);
        mplew.writeInt(CHAR_MAGIC_SPAWN);
        mplew.writeShort(0);

        mplew.writeShort(chr.getJob());
        mplew.writeShort(chr.getSubcategory());
        PacketHelper.addCharLook(mplew, chr, true, false);
        if (GameConstants.isZero(chr.getJob())) {
            PacketHelper.addCharLook(mplew, chr, true, false);
        }

        mplew.writeInt(0);
        mplew.writeInt(0);

        mplew.writeInt(Math.min(250, chr.getInventory(MapleInventoryType.CASH).countById(5110000))); //Valentine Effect
        mplew.writeInt(0);
        mplew.writeInt(0);

        mplew.writeInt(0);
        mplew.writeInt(0);
        mplew.writeInt(0);
        MapleQuestStatus stat = chr.getQuestNoAdd(MapleQuest.getInstance(124000));
        mplew.writeInt(stat != null && stat.getCustomData() != null ? Integer.parseInt(stat.getCustomData()) : 0); //title
        mplew.writeInt(0);
        mplew.writeInt(0);
        mplew.writeInt(0);
        mplew.writeInt(chr.getItemEffect());
        mplew.writeInt(GameConstants.getInventoryType(chr.getChair()) == MapleInventoryType.SETUP ? chr.getChair() : 0);
        mplew.writeInt(0);
        mplew.writeInt(0); //new v143
        mplew.writeInt(0); //new v149
        mplew.writePos(chr.getTruePosition());
        mplew.write(chr.getStance());
        mplew.writeShort(chr.getFH());
        mplew.write(0);
        mplew.write(0);
        mplew.write(0);

        mplew.write(1);
        mplew.write(0);

        mplew.writeInt(chr.getMount().getLevel());
        mplew.writeInt(chr.getMount().getExp());
        mplew.writeInt(chr.getMount().getFatigue());

        PacketHelper.addAnnounceBox(mplew, chr);
        mplew.write((chr.getChalkboard() != null) && (chr.getChalkboard().length() > 0) ? 1 : 0);
        if ((chr.getChalkboard() != null) && (chr.getChalkboard().length() > 0)) {
            mplew.writeMapleAsciiString(chr.getChalkboard());
        }

        Triple rings = chr.getRings(false);
        addRingInfo(mplew, (List) rings.getLeft());
        addRingInfo(mplew, (List) rings.getMid());
        addMRingInfo(mplew, (List) rings.getRight(), chr);

        mplew.write(chr.getStat().Berserk ? 1 : 0); //mask
        mplew.writeInt(0);

        if (GameConstants.isKaiser(chr.getJob())) {
            String x = chr.getOneInfo(12860, "extern");
            mplew.writeInt(x == null ? 0 : Integer.parseInt(x));
            x = chr.getOneInfo(12860, "inner");
            mplew.writeInt(x == null ? 0 : Integer.parseInt(x));
            x = chr.getOneInfo(12860, "premium");
            mplew.write(x == null ? 0 : Integer.parseInt(x));
        }

        mplew.write(0); //new v142->v143
        mplew.writeInt(0); //new v142->v143
        //mplew.writeZeroBytes(6); // removed v149.2 ?
        PacketHelper.addFarmInfo(mplew, chr.getClient(), 0);
        for (int i = 0; i < 5; i++) {
            mplew.write(-1);
        }

        mplew.writeInt(0);
        mplew.write(0);
        mplew.writeInt(0);
        mplew.writeInt(0); //v145

        
        return mplew.getPacket();
    }