mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-15 00:15:33 +01:00
Merge branch 'dev-scene'
This commit is contained in:
@@ -78,6 +78,7 @@ public class GenshinPlayer {
|
||||
@Transient private long nextGuid = 0;
|
||||
@Transient private int peerId;
|
||||
@Transient private World world;
|
||||
@Transient private GenshinScene scene;
|
||||
@Transient private GameSession session;
|
||||
@Transient private AvatarStorage avatars;
|
||||
@Transient private Inventory inventory;
|
||||
@@ -155,17 +156,17 @@ public class GenshinPlayer {
|
||||
this.getRotation().set(0, 307, 0);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public int getUid() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
public void setUid(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getNextGuid() {
|
||||
public long getNextGenshinGuid() {
|
||||
long nextId = ++this.nextGuid;
|
||||
return ((long) this.getId() << 32) + nextId;
|
||||
return ((long) this.getUid() << 32) + nextId;
|
||||
}
|
||||
|
||||
public Account getAccount() {
|
||||
@@ -174,7 +175,7 @@ public class GenshinPlayer {
|
||||
|
||||
public void setAccount(Account account) {
|
||||
this.account = account;
|
||||
this.account.setPlayerId(getId());
|
||||
this.account.setPlayerId(getUid());
|
||||
}
|
||||
|
||||
public GameSession getSession() {
|
||||
@@ -201,6 +202,14 @@ public class GenshinPlayer {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public GenshinScene getScene() {
|
||||
return scene;
|
||||
}
|
||||
|
||||
public void setScene(GenshinScene scene) {
|
||||
this.scene = scene;
|
||||
}
|
||||
|
||||
public int getGmLevel() {
|
||||
return 1;
|
||||
}
|
||||
@@ -551,7 +560,16 @@ public class GenshinPlayer {
|
||||
}
|
||||
|
||||
public void dropMessage(Object message) {
|
||||
this.sendPacket(new PacketPrivateChatNotify(GenshinConstants.SERVER_CONSOLE_UID, getId(), message.toString()));
|
||||
this.sendPacket(new PacketPrivateChatNotify(GenshinConstants.SERVER_CONSOLE_UID, getUid(), message.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to another player.
|
||||
* @param sender The sender of the message.
|
||||
* @param message The message to send.
|
||||
*/
|
||||
public void sendMessage(GenshinPlayer sender, Object message) {
|
||||
this.sendPacket(new PacketPrivateChatNotify(sender.getUid(), this.getUid(), message.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -564,14 +582,14 @@ public class GenshinPlayer {
|
||||
}
|
||||
|
||||
public void interactWith(int gadgetEntityId) {
|
||||
GenshinEntity entity = getWorld().getEntityById(gadgetEntityId);
|
||||
GenshinEntity entity = getScene().getEntityById(gadgetEntityId);
|
||||
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete
|
||||
entity.getWorld().removeEntity(entity);
|
||||
entity.getScene().removeEntity(entity);
|
||||
|
||||
// Handle
|
||||
if (entity instanceof EntityItem) {
|
||||
@@ -605,7 +623,7 @@ public class GenshinPlayer {
|
||||
|
||||
public OnlinePlayerInfo getOnlinePlayerInfo() {
|
||||
OnlinePlayerInfo.Builder onlineInfo = OnlinePlayerInfo.newBuilder()
|
||||
.setUid(this.getId())
|
||||
.setUid(this.getUid())
|
||||
.setNickname(this.getNickname())
|
||||
.setPlayerLevel(this.getLevel())
|
||||
.setMpSettingType(this.getMpSetting())
|
||||
@@ -624,7 +642,7 @@ public class GenshinPlayer {
|
||||
|
||||
public SocialDetail.Builder getSocialDetail() {
|
||||
SocialDetail.Builder social = SocialDetail.newBuilder()
|
||||
.setUid(this.getId())
|
||||
.setUid(this.getUid())
|
||||
.setAvatar(HeadImage.newBuilder().setAvatarId(this.getHeadImage()))
|
||||
.setNickname(this.getNickname())
|
||||
.setSignature(this.getSignature())
|
||||
@@ -640,7 +658,7 @@ public class GenshinPlayer {
|
||||
|
||||
public PlayerLocationInfo getPlayerLocationInfo() {
|
||||
return PlayerLocationInfo.newBuilder()
|
||||
.setUid(this.getId())
|
||||
.setUid(this.getUid())
|
||||
.setPos(this.getPos().toProto())
|
||||
.setRot(this.getRotation().toProto())
|
||||
.build();
|
||||
@@ -690,7 +708,7 @@ public class GenshinPlayer {
|
||||
|
||||
// Check if player object exists in server
|
||||
// TODO - optimize
|
||||
GenshinPlayer exists = this.getServer().getPlayerById(getId());
|
||||
GenshinPlayer exists = this.getServer().getPlayerByUid(getUid());
|
||||
if (exists != null) {
|
||||
exists.getSession().close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user