From fb9f6c0bf4b42a4a17c56e4eadb48263c0db2ea0 Mon Sep 17 00:00:00 2001 From: Yazawazi <47273265+Yazawazi@users.noreply.github.com> Date: Sun, 24 Apr 2022 15:02:31 +0800 Subject: [PATCH] Fix fetter system --- .../emu/grasscutter/game/avatar/GenshinAvatar.java | 12 ++++++++---- .../recv/HandlerAvatarFetterLevelRewardReq.java | 4 +++- .../packet/send/PacketAvatarFetterDataNotify.java | 12 ++++++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java b/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java index ab2f67a43..b6007e280 100644 --- a/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java @@ -743,9 +743,14 @@ public class GenshinAvatar { } public AvatarInfo toProto() { + int fetterLevel = this.getFetterLevel(); AvatarFetterInfo.Builder avatarFetter = AvatarFetterInfo.newBuilder() - .setExpLevel(this.getFetterLevel()) - .setExpNumber(this.getFetterExp()); + .setExpLevel(fetterLevel); + + if (fetterLevel != 10) { + avatarFetter.setExpNumber(this.getFetterExp()); + } + if (this.getFetterList() != null) { for (int i = 0; i < this.getFetterList().size(); i++) { @@ -757,11 +762,10 @@ public class GenshinAvatar { } } - int rewardId = this.getNameCardRewardId(); int cardId = this.getNameCardId(); if (this.getPlayer().getNameCardList().contains(cardId)) { - avatarFetter.addRewardedFetterLevelList(rewardId); + avatarFetter.addRewardedFetterLevelList(10); } AvatarInfo.Builder avatarInfo = AvatarInfo.newBuilder() diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java index 51192f620..b8b4f5e57 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java @@ -9,6 +9,7 @@ import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.AvatarFetterLevelRewardReqOuterClass.AvatarFetterLevelRewardReq; import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketAvatarDataNotify; import emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify; import emu.grasscutter.server.packet.send.PacketAvatarFetterLevelRewardRsp; import emu.grasscutter.server.packet.send.PacketItemAddHintNotify; @@ -46,8 +47,9 @@ public class HandlerAvatarFetterLevelRewardReq extends PacketHandler { session.getPlayer().getInventory().addItem(item); session.getPlayer().sendPacket(new PacketItemAddHintNotify(item, ActionReason.FetterLevelReward)); session.getPlayer().sendPacket(new PacketUnlockNameCardNotify(cardId)); - session.send(new PacketAvatarFetterLevelRewardRsp(avatarGuid, req.getFetterLevel(), rewardId)); session.send(new PacketAvatarFetterDataNotify(avatar)); + session.send(new PacketAvatarDataNotify(avatar.getPlayer())); + session.send(new PacketAvatarFetterLevelRewardRsp(avatarGuid, req.getFetterLevel(), rewardId)); } } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterDataNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterDataNotify.java index 6be12e603..68d3dbeac 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterDataNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterDataNotify.java @@ -13,9 +13,14 @@ public class PacketAvatarFetterDataNotify extends GenshinPacket { public PacketAvatarFetterDataNotify(GenshinAvatar avatar) { super(PacketOpcodes.AvatarFetterDataNotify); + int fetterLevel = avatar.getFetterLevel(); + AvatarFetterInfo.Builder avatarFetter = AvatarFetterInfo.newBuilder() - .setExpLevel(avatar.getFetterLevel()) - .setExpNumber(avatar.getFetterExp()); + .setExpLevel(avatar.getFetterLevel()); + + if (fetterLevel != 10) { + avatarFetter.setExpNumber(avatar.getFetterExp()); + } if (avatar.getFetterList() != null) { for (int i = 0; i < avatar.getFetterList().size(); i++) { @@ -27,11 +32,10 @@ public class PacketAvatarFetterDataNotify extends GenshinPacket { } } - int rewardId = avatar.getNameCardRewardId(); int cardId = avatar.getNameCardId(); if (avatar.getPlayer().getNameCardList().contains(cardId)) { - avatarFetter.addRewardedFetterLevelList(rewardId); + avatarFetter.addRewardedFetterLevelList(10); } AvatarFetterInfo avatarFetterInfo = avatarFetter.build();