Commit 7925d1cd authored by Melledy's avatar Melledy
Browse files

Initial commit

parents
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.World;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.HostPlayerNotifyOuterClass.HostPlayerNotify;
public class PacketHostPlayerNotify extends GenshinPacket {
public PacketHostPlayerNotify(World world) {
super(PacketOpcodes.HostPlayerNotify);
HostPlayerNotify proto = HostPlayerNotify.newBuilder()
.setHostUid(world.getHost().getId())
.setHostPeerId(world.getHost().getPeerId())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import java.util.List;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ItemAddHintNotifyOuterClass.ItemAddHintNotify;
public class PacketItemAddHintNotify extends GenshinPacket {
public PacketItemAddHintNotify(GenshinItem item, ActionReason reason) {
super(PacketOpcodes.ItemAddHintNotify);
ItemAddHintNotify proto = ItemAddHintNotify.newBuilder()
.addItemList(item.toItemHintProto())
.setReason(reason.getValue())
.build();
this.setData(proto);
}
public PacketItemAddHintNotify(List<GenshinItem> items, ActionReason reason) {
super(PacketOpcodes.ItemAddHintNotify);
ItemAddHintNotify.Builder proto = ItemAddHintNotify.newBuilder()
.setReason(reason.getValue());
for (GenshinItem item : items) {
proto.addItemList(item.toItemHintProto());
}
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.entity.GenshinEntity;
import emu.grasscutter.game.props.LifeState;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.LifeStateChangeNotifyOuterClass.LifeStateChangeNotify;
public class PacketLifeStateChangeNotify extends GenshinPacket {
public PacketLifeStateChangeNotify(GenshinEntity attacker, GenshinEntity target, LifeState lifeState) {
super(PacketOpcodes.LifeStateChangeNotify);
LifeStateChangeNotify proto = LifeStateChangeNotify.newBuilder()
.setEntityId(target.getId())
.setLifeState(lifeState.getValue())
.setSourceEntityId(attacker.getId())
.build();
this.setData(proto);
}
public PacketLifeStateChangeNotify(int attackerId, GenshinEntity target, LifeState lifeState) {
super(PacketOpcodes.LifeStateChangeNotify);
LifeStateChangeNotify proto = LifeStateChangeNotify.newBuilder()
.setEntityId(target.getId())
.setLifeState(lifeState.getValue())
.setSourceEntityId(attackerId)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.props.OpenState;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.OpenStateUpdateNotifyOuterClass.OpenStateUpdateNotify;
public class PacketOpenStateUpdateNotify extends GenshinPacket {
public PacketOpenStateUpdateNotify() {
super(PacketOpcodes.OpenStateUpdateNotify);
OpenStateUpdateNotify.Builder proto = OpenStateUpdateNotify.newBuilder();
for (OpenState type : OpenState.values()) {
if (type.getValue() > 0) {
proto.putOpenStateMap(type.getValue(), 1);
}
}
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
public class PacketPathfindingEnterSceneRsp extends GenshinPacket {
public PacketPathfindingEnterSceneRsp(int clientSequence) {
super(PacketOpcodes.PathfindingEnterSceneRsp);
this.buildHeader(clientSequence);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PingRspOuterClass.PingRsp;
public class PacketPingRsp extends GenshinPacket {
public PacketPingRsp(int clientSeq, int time) {
super(PacketOpcodes.PingRsp, clientSeq);
PingRsp p = PingRsp.newBuilder()
.setClientTime(time)
.build();
this.setData(p.toByteArray());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerApplyEnterMpNotifyOuterClass.PlayerApplyEnterMpNotify;
public class PacketPlayerApplyEnterMpNotify extends GenshinPacket {
public PacketPlayerApplyEnterMpNotify(GenshinPlayer srcPlayer) {
super(PacketOpcodes.PlayerApplyEnterMpNotify);
PlayerApplyEnterMpNotify proto = PlayerApplyEnterMpNotify.newBuilder()
.setSrcPlayerInfo(srcPlayer.getOnlinePlayerInfo())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason;
import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify;
public class PacketPlayerApplyEnterMpResultNotify extends GenshinPacket {
public PacketPlayerApplyEnterMpResultNotify(GenshinPlayer target, boolean isAgreed, PlayerApplyEnterMpReason reason) {
super(PacketOpcodes.PlayerApplyEnterMpResultNotify);
PlayerApplyEnterMpResultNotify proto = PlayerApplyEnterMpResultNotify.newBuilder()
.setTargetUid(target.getId())
.setTargetNickname(target.getNickname())
.setIsAgreed(isAgreed)
.setReason(reason)
.build();
this.setData(proto);
}
public PacketPlayerApplyEnterMpResultNotify(int targetId, String targetName, boolean isAgreed, PlayerApplyEnterMpReason reason) {
super(PacketOpcodes.PlayerApplyEnterMpResultNotify);
PlayerApplyEnterMpResultNotify proto = PlayerApplyEnterMpResultNotify.newBuilder()
.setTargetUid(targetId)
.setTargetNickname(targetName)
.setIsAgreed(isAgreed)
.setReason(reason)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerApplyEnterMpResultRspOuterClass.PlayerApplyEnterMpResultRsp;
public class PacketPlayerApplyEnterMpResultRsp extends GenshinPacket {
public PacketPlayerApplyEnterMpResultRsp(int applyUid, boolean isAgreed) {
super(PacketOpcodes.PlayerApplyEnterMpResultRsp);
PlayerApplyEnterMpResultRsp proto = PlayerApplyEnterMpResultRsp.newBuilder()
.setApplyUid(applyUid)
.setIsAgreed(isAgreed)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerApplyEnterMpRspOuterClass.PlayerApplyEnterMpRsp;
public class PacketPlayerApplyEnterMpRsp extends GenshinPacket {
public PacketPlayerApplyEnterMpRsp(int targetUid) {
super(PacketOpcodes.PlayerApplyEnterMpRsp);
PlayerApplyEnterMpRsp proto = PlayerApplyEnterMpRsp.newBuilder()
.setTargetUid(targetUid)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ChatInfoOuterClass.ChatInfo;
import emu.grasscutter.net.proto.PlayerChatNotifyOuterClass.PlayerChatNotify;
import emu.grasscutter.net.proto.SystemHintOuterClass.SystemHint;
public class PacketPlayerChatNotify extends GenshinPacket {
public PacketPlayerChatNotify(GenshinPlayer sender, int channelId, String message) {
super(PacketOpcodes.PlayerChatNotify);
ChatInfo info = ChatInfo.newBuilder()
.setTime((int) (System.currentTimeMillis() / 1000))
.setUid(sender.getId())
.setText(message)
.build();
PlayerChatNotify proto = PlayerChatNotify.newBuilder()
.setChannelId(channelId)
.setChatInfo(info)
.build();
this.setData(proto);
}
public PacketPlayerChatNotify(GenshinPlayer sender, int channelId, int emote) {
super(PacketOpcodes.PlayerChatNotify);
ChatInfo info = ChatInfo.newBuilder()
.setTime((int) (System.currentTimeMillis() / 1000))
.setUid(sender.getId())
.setIcon(emote)
.build();
PlayerChatNotify proto = PlayerChatNotify.newBuilder()
.setChannelId(channelId)
.setChatInfo(info)
.build();
this.setData(proto);
}
public PacketPlayerChatNotify(GenshinPlayer sender, int channelId, SystemHint systemHint) {
super(PacketOpcodes.PlayerChatNotify);
ChatInfo info = ChatInfo.newBuilder()
.setTime((int) (System.currentTimeMillis() / 1000))
.setUid(sender.getId())
.setSystemHint(systemHint)
.build();
PlayerChatNotify proto = PlayerChatNotify.newBuilder()
.setChannelId(channelId)
.setChatInfo(info)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerChatRspOuterClass.PlayerChatRsp;
public class PacketPlayerChatRsp extends GenshinPacket {
public PacketPlayerChatRsp() {
super(PacketOpcodes.PlayerChatRsp);
PlayerChatRsp proto = PlayerChatRsp.newBuilder().build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerDataNotifyOuterClass.PlayerDataNotify;
import emu.grasscutter.net.proto.PropValueOuterClass.PropValue;
public class PacketPlayerDataNotify extends GenshinPacket {
public PacketPlayerDataNotify(GenshinPlayer player) {
super(PacketOpcodes.PlayerDataNotify, 2);
PlayerDataNotify.Builder p = PlayerDataNotify.newBuilder()
.setNickName(player.getNickname())
.setClientTime(System.currentTimeMillis())
.setIsFirstLoginToday(true)
.setRegionId(player.getRegionId());
player.getProperties().forEach((key, value) -> {
p.putPropMap(key, PropValue.newBuilder().setType(key).setIval(value).setVal(value).build());
});
this.setData(p.build());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo;
import emu.grasscutter.net.proto.AvatarEnterSceneInfoOuterClass.AvatarEnterSceneInfo;
import emu.grasscutter.net.proto.MPLevelEntityInfoOuterClass.MPLevelEntityInfo;
import emu.grasscutter.net.proto.PlayerEnterSceneInfoNotifyOuterClass.PlayerEnterSceneInfoNotify;
import emu.grasscutter.net.proto.TeamEnterSceneInfoOuterClass.TeamEnterSceneInfo;
public class PacketPlayerEnterSceneInfoNotify extends GenshinPacket {
public PacketPlayerEnterSceneInfoNotify(GenshinPlayer player) {
super(PacketOpcodes.PlayerEnterSceneInfoNotify);
AbilitySyncStateInfo empty = AbilitySyncStateInfo.newBuilder().build();
PlayerEnterSceneInfoNotify.Builder proto = PlayerEnterSceneInfoNotify.newBuilder()
.setCurAvatarEntityId(player.getTeamManager().getCurrentAvatarEntity().getId())
.setEnterSceneToken(player.getEnterSceneToken());
proto.setTeamEnterInfo(
TeamEnterSceneInfo.newBuilder()
.setTeamEntityId(player.getTeamManager().getEntityId()) // 150995833
.setTeamAbilityInfo(empty)
.setUnk(empty)
);
proto.setMpLevelEntityInfo(
MPLevelEntityInfo.newBuilder()
.setEntityId(player.getWorld().getLevelEntityId()) // 184550274
.setAuthorityPeerId(player.getWorld().getHostPeerId())
.setAbilityInfo(empty)
);
for (EntityAvatar avatarEntity : player.getTeamManager().getActiveTeam()) {
GenshinItem weapon = avatarEntity.getAvatar().getWeapon();
long weaponGuid = weapon != null ? weapon.getGuid() : 0;
AvatarEnterSceneInfo avatarInfo = AvatarEnterSceneInfo.newBuilder()
.setAvatarGuid(avatarEntity.getAvatar().getGuid())
.setAvatarEntityId(avatarEntity.getId())
.setWeaponGuid(weaponGuid)
.setWeaponEntityId(avatarEntity.getWeaponEntityId())
.setAvatarAbilityInfo(empty)
.setWeaponAbilityInfo(empty)
.build();
proto.addAvatarEnterInfo(avatarInfo);
}
this.setData(proto.build());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.GenshinPlayer.SceneLoadState;
import emu.grasscutter.game.props.EnterReason;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType;
import emu.grasscutter.net.proto.PlayerEnterSceneNotifyOuterClass.PlayerEnterSceneNotify;
import emu.grasscutter.utils.Position;
import emu.grasscutter.utils.Utils;
public class PacketPlayerEnterSceneNotify extends GenshinPacket {
// Login
public PacketPlayerEnterSceneNotify(GenshinPlayer player) {
super(PacketOpcodes.PlayerEnterSceneNotify);
player.setSceneLoadState(SceneLoadState.LOADING);
player.setEnterSceneToken(Utils.randomRange(1000, 99999));
PlayerEnterSceneNotify proto = PlayerEnterSceneNotify.newBuilder()
.setSceneId(player.getSceneId())
.setPos(player.getPos().toProto())
.setSceneBeginTime(System.currentTimeMillis())
.setType(EnterType.EnterSelf)
.setTargetUid(player.getId())
.setEnterSceneToken(player.getEnterSceneToken())
.setWorldLevel(player.getWorldLevel())
.setEnterReason(EnterReason.Login.getValue())
.setIsFirstLoginEnterScene(player.isFirstLoginEnterScene())
.addSceneTagIdList(102)
.addSceneTagIdList(107)
.addSceneTagIdList(113)
.addSceneTagIdList(117)
.setUnk1(1)
.setUnk2("3-" + player.getId() + "-" + (int) (System.currentTimeMillis() / 1000) + "-" + 18402)
.build();
this.setData(proto);
}
public PacketPlayerEnterSceneNotify(GenshinPlayer player, EnterType type, EnterReason reason, int newScene, Position newPos) {
this(player, player, type, reason, newScene, newPos);
}
// Teleport or go somewhere
public PacketPlayerEnterSceneNotify(GenshinPlayer player, GenshinPlayer target, EnterType type, EnterReason reason, int newScene, Position newPos) {
super(PacketOpcodes.PlayerEnterSceneNotify);
player.setEnterSceneToken(Utils.randomRange(1000, 99999));
PlayerEnterSceneNotify proto = PlayerEnterSceneNotify.newBuilder()
.setPrevSceneId(player.getSceneId())
.setPrevPos(player.getPos().toProto())
.setSceneId(newScene)
.setPos(newPos.toProto())
.setSceneBeginTime(System.currentTimeMillis())
.setType(EnterType.EnterSelf)
.setTargetUid(target.getId())
.setEnterSceneToken(player.getEnterSceneToken())
.setWorldLevel(target.getWorld().getWorldLevel())
.setEnterReason(reason.getValue())
.addSceneTagIdList(102)
.addSceneTagIdList(107)
.addSceneTagIdList(113)
.addSceneTagIdList(117)
.setUnk1(1)
.setUnk2(newScene + "-" + target.getId() + "-" + (int) (System.currentTimeMillis() / 1000) + "-" + 18402)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.World;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerGameTimeNotifyOuterClass.PlayerGameTimeNotify;
public class PacketPlayerGameTimeNotify extends GenshinPacket {
public PacketPlayerGameTimeNotify(World world, GenshinPlayer player) {
super(PacketOpcodes.PlayerGameTimeNotify);
PlayerGameTimeNotify proto = PlayerGameTimeNotify.newBuilder()
.setGameTime(world.getTime())
.setUid(player.getId())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerGetForceQuitBanInfoRspOuterClass.PlayerGetForceQuitBanInfoRsp;
public class PacketPlayerGetForceQuitBanInfoRsp extends GenshinPacket {
public PacketPlayerGetForceQuitBanInfoRsp(int retcode) {
super(PacketOpcodes.PlayerGetForceQuitBanInfoRsp);
PlayerGetForceQuitBanInfoRsp proto = PlayerGetForceQuitBanInfoRsp.newBuilder()
.setRetcode(retcode)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerLoginRspOuterClass.PlayerLoginRsp;
import emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo;
import emu.grasscutter.server.game.GameSession;
public class PacketPlayerLoginRsp extends GenshinPacket {
public PacketPlayerLoginRsp(GameSession session) {
super(PacketOpcodes.PlayerLoginRsp, 1);
this.setUseDispatchKey(true);
RegionInfo info = Grasscutter.getDispatchServer().getCurrRegion().getRegionInfo();
PlayerLoginRsp p = PlayerLoginRsp.newBuilder()
.setIsUseAbilityHash(true) // true
.setAbilityHashCode(1844674) // 1844674
.setGameBiz("hk4e_global")
.setClientDataVersion(info.getClientDataVersion())
.setClientSilenceDataVersion(info.getClientSilenceDataVersion())
.setClientMd5(info.getClientDataMd5())
.setClientSilenceMd5(info.getClientSilenceDataMd5())
.setResVersionConfig(info.getConfig())
.setClientVersionSuffix(info.getClientVersionSuffix())
.setClientSilenceVersionSuffix(info.getClientSilenceVersionSuffix())
.setIsScOpen(false)
//.setScInfo(ByteString.copyFrom(new byte[] {}))
.setRegisterCps("mihoyo")
.setCountryCode("US")
.build();
this.setData(p.toByteArray());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerPropNotifyOuterClass.PlayerPropNotify;
import emu.grasscutter.utils.ProtoHelper;
public class PacketPlayerPropNotify extends GenshinPacket {
public PacketPlayerPropNotify(GenshinPlayer player, PlayerProperty prop) {
super(PacketOpcodes.PlayerPropNotify);
this.buildHeader(0);
PlayerPropNotify proto = PlayerPropNotify.newBuilder()
.putPropMap(prop.getId(), ProtoHelper.newPropValue(prop, player.getProperty(prop)))
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
public class PacketPlayerSetPauseRsp extends GenshinPacket {
public PacketPlayerSetPauseRsp(int clientSequence) {
super(PacketOpcodes.PlayerSetPauseRsp);
this.buildHeader(clientSequence);
}
}
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