Set setChooseAvatarGuid properly

This commit is contained in:
Melledy 2022-07-22 08:30:11 -07:00
parent 0d17c4a088
commit 7254fe1612
2 changed files with 12 additions and 3 deletions

View File

@ -642,6 +642,9 @@ public class Player {
} }
public void setMainCharacterId(int mainCharacterId) { public void setMainCharacterId(int mainCharacterId) {
if (this.mainCharacterId != 0) {
return;
}
this.mainCharacterId = mainCharacterId; this.mainCharacterId = mainCharacterId;
} }

View File

@ -13,11 +13,11 @@ import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
public class PacketAvatarDataNotify extends BasePacket { public class PacketAvatarDataNotify extends BasePacket {
public PacketAvatarDataNotify(Player player) { public PacketAvatarDataNotify(Player player) {
super(PacketOpcodes.AvatarDataNotify, 2); super(PacketOpcodes.AvatarDataNotify, true);
AvatarDataNotify.Builder proto = AvatarDataNotify.newBuilder() AvatarDataNotify.Builder proto = AvatarDataNotify.newBuilder()
.setCurAvatarTeamId(player.getTeamManager().getCurrentTeamId()) .setCurAvatarTeamId(player.getTeamManager().getCurrentTeamId())
.setChooseAvatarGuid(player.getTeamManager().getCurrentCharacterGuid()) //.setChooseAvatarGuid(player.getTeamManager().getCurrentCharacterGuid())
.addAllOwnedFlycloakList(player.getFlyCloakList()) .addAllOwnedFlycloakList(player.getFlyCloakList())
.addAllOwnedCostumeList(player.getCostumeList()); .addAllOwnedCostumeList(player.getCostumeList());
@ -38,6 +38,12 @@ public class PacketAvatarDataNotify extends BasePacket {
proto.putAvatarTeamMap(entry.getKey(), avatarTeam.build()); proto.putAvatarTeamMap(entry.getKey(), avatarTeam.build());
} }
// Set main character
Avatar mainCharacter = player.getAvatars().getAvatarById(player.getMainCharacterId());
if (mainCharacter != null) {
proto.setChooseAvatarGuid(mainCharacter.getGuid());
}
this.setData(proto.build()); this.setData(proto.build());
} }