Commit a5720973 authored by Magix's avatar Magix Committed by GitHub
Browse files

Merge branch 'development' into main

parents 708ee021 16318b37
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.custom.ScenePointEntry;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.SceneTransToPointReqOuterClass.SceneTransToPointReq;
import emu.grasscutter.net.proto.SceneTransToPointRspOuterClass.SceneTransToPointRsp;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketSceneTransToPointRsp;
import emu.grasscutter.utils.Position;
@Opcodes(PacketOpcodes.SceneTransToPointReq)
public class HandlerSceneTransToPointReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
SceneTransToPointReq req = SceneTransToPointReq.parseFrom(payload);
String code = req.getSceneId() + "_" + req.getPointId();
ScenePointEntry scenePointEntry = GenshinData.getScenePointEntries().get(code);
if (scenePointEntry != null) {
float x = scenePointEntry.getPointData().getTranPos().getX();
float y = scenePointEntry.getPointData().getTranPos().getY();
float z = scenePointEntry.getPointData().getTranPos().getZ();
session.getPlayer().getWorld().transferPlayerToScene(session.getPlayer(), req.getSceneId(), new Position(x, y, z));
session.send(new PacketSceneTransToPointRsp(session.getPlayer(), req.getPointId(), req.getSceneId()));
} else {
session.send(new PacketSceneTransToPointRsp());
}
}
}
package emu.grasscutter.server.packet.recv; package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.SetEntityClientDataNotifyOuterClass.SetEntityClientDataNotify;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
...@@ -10,7 +12,18 @@ public class HandlerSetEntityClientDataNotify extends PacketHandler { ...@@ -10,7 +12,18 @@ public class HandlerSetEntityClientDataNotify extends PacketHandler {
@Override @Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
// Auto template // Skip if there is no one to broadcast it too
if (session.getPlayer().getScene().getPlayerCount() <= 1) {
return;
}
// Make sure packet is a valid proto before replaying it to the other players
SetEntityClientDataNotify notif = SetEntityClientDataNotify.parseFrom(payload);
GenshinPacket packet = new GenshinPacket(PacketOpcodes.SetEntityClientDataNotify, true);
packet.setData(notif);
session.getPlayer().getScene().broadcastPacketToOthers(session.getPlayer(), packet);
} }
} }
...@@ -43,7 +43,7 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler { ...@@ -43,7 +43,7 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
try { try {
// Save to db // Save to db
DatabaseHelper.createPlayer(player, session.getAccount().getPlayerId()); DatabaseHelper.createPlayer(player, session.getAccount().getPlayerUid());
// Create avatar // Create avatar
if (player.getAvatars().getAvatarCount() == 0) { if (player.getAvatars().getAvatarCount() == 0) {
......
...@@ -8,7 +8,7 @@ import emu.grasscutter.net.proto.AbilityChangeNotifyOuterClass.AbilityChangeNoti ...@@ -8,7 +8,7 @@ import emu.grasscutter.net.proto.AbilityChangeNotifyOuterClass.AbilityChangeNoti
public class PacketAbilityChangeNotify extends GenshinPacket { public class PacketAbilityChangeNotify extends GenshinPacket {
public PacketAbilityChangeNotify(EntityAvatar entity) { public PacketAbilityChangeNotify(EntityAvatar entity) {
super(PacketOpcodes.AbilityChangeNotify); super(PacketOpcodes.AbilityChangeNotify, true);
AbilityChangeNotify proto = AbilityChangeNotify.newBuilder() AbilityChangeNotify proto = AbilityChangeNotify.newBuilder()
.setEntityId(entity.getId()) .setEntityId(entity.getId())
......
package emu.grasscutter.server.packet.send;
import java.util.List;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry;
import emu.grasscutter.net.proto.ClientAbilityInitFinishNotifyOuterClass.ClientAbilityInitFinishNotify;
public class PacketClientAbilityInitFinishNotify extends GenshinPacket {
public PacketClientAbilityInitFinishNotify(List<AbilityInvokeEntry> entries) {
super(PacketOpcodes.ClientAbilityInitFinishNotify, true);
int entityId = 0;
if (entries.size() > 0) {
AbilityInvokeEntry entry = entries.get(0);
entityId = entry.getEntityId();
}
ClientAbilityInitFinishNotify proto = ClientAbilityInitFinishNotify.newBuilder()
.setEntityId(entityId)
.addAllInvokes(entries)
.build();
this.setData(proto);
}
}
...@@ -23,7 +23,6 @@ public class PacketGetPlayerFriendListRsp extends GenshinPacket { ...@@ -23,7 +23,6 @@ public class PacketGetPlayerFriendListRsp extends GenshinPacket {
.setWorldLevel(0) .setWorldLevel(0)
.setSignature("") .setSignature("")
.setLastActiveTime((int) (System.currentTimeMillis() / 1000f)) .setLastActiveTime((int) (System.currentTimeMillis() / 1000f))
.setIsMpModeAvailable(true)
.setNameCardId(210001) .setNameCardId(210001)
.setOnlineState(FriendOnlineState.FRIEND_ONLINE) .setOnlineState(FriendOnlineState.FRIEND_ONLINE)
.setParam(1) .setParam(1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment