diff --git a/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java b/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java index 418f16a4b..365055e26 100644 --- a/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java +++ b/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java @@ -1034,6 +1034,8 @@ public class PacketOpcodes { public static final int ShowTemplateReminderNotify = 3164; public static final int SignInInfoReq = 2510; public static final int SignInInfoRsp = 2515; + public static final int SitReq = 354; + public static final int SitRsp = 335; public static final int SocialDataNotify = 4063; public static final int SpringUseReq = 1720; public static final int SpringUseRsp = 1727; @@ -1208,5 +1210,4 @@ public class PacketOpcodes { public static final int WorldRoutineChangeNotify = 3548; public static final int WorldRoutineTypeCloseNotify = 3513; public static final int WorldRoutineTypeRefreshNotify = 3545; - } \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandleEvtAvatarSitDownNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandleEvtAvatarSitDownNotify.java new file mode 100644 index 000000000..8f653dde9 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandleEvtAvatarSitDownNotify.java @@ -0,0 +1,21 @@ +package emu.grasscutter.server.packet.recv; + +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify; +import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketEvtAvatarSitDownNotify; + +@Opcodes(PacketOpcodes.EvtAvatarSitDownNotify) +public class HandleEvtAvatarSitDownNotify extends PacketHandler { + + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + EvtAvatarSitDownNotify notify = EvtAvatarSitDownNotify.parseFrom(payload); + + session.send(new PacketEvtAvatarSitDownNotify(notify)); + } + +} + diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandleSitReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandleSitReq.java new file mode 100644 index 000000000..418d99eef --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandleSitReq.java @@ -0,0 +1,24 @@ +package emu.grasscutter.server.packet.recv; + +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.SitReqOuterClass; +import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketSitRsp; +import emu.grasscutter.utils.Position; + +@Opcodes(PacketOpcodes.SitReq) +public class HandleSitReq extends PacketHandler { + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + SitReqOuterClass.SitReq req = SitReqOuterClass.SitReq.parseFrom(payload); + + float x = req.getPosition().getX(); + float y = req.getPosition().getY(); + float z = req.getPosition().getZ(); + + session.send(new PacketSitRsp(req.getChairId(), new Position(x, y, z), session.getPlayer().getTeamManager().getCurrentAvatarEntity().getId())); + } + +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketEvtAvatarSitDownNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketEvtAvatarSitDownNotify.java new file mode 100644 index 000000000..6a051024a --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketEvtAvatarSitDownNotify.java @@ -0,0 +1,20 @@ +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.net.packet.GenshinPacket; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify; + +public class PacketEvtAvatarSitDownNotify extends GenshinPacket { + + public PacketEvtAvatarSitDownNotify(EvtAvatarSitDownNotify notify) { + super(PacketOpcodes.EvtAvatarSitDownNotify); + + EvtAvatarSitDownNotify proto = EvtAvatarSitDownNotify.newBuilder() + .setEntityId(notify.getEntityId()) + .setPosition(notify.getPosition()) + .setChairId(notify.getChairId()) + .build(); + + this.setData(proto); + } +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSitRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSitRsp.java new file mode 100644 index 000000000..70893965b --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSitRsp.java @@ -0,0 +1,21 @@ +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.net.packet.GenshinPacket; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.SitRspOuterClass.SitRsp; +import emu.grasscutter.utils.Position; + +public class PacketSitRsp extends GenshinPacket { + + public PacketSitRsp(long chairId, Position pos, int EntityId) { + super(PacketOpcodes.SitRsp); + + SitRsp proto = SitRsp.newBuilder() + .setEntityId(EntityId) + .setPosition(pos.toProto()) + .setChairId(chairId) + .build(); + + this.setData(proto); + } +}