mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 07:10:46 +00:00
Dont deregister scenes if the player is going to tp back into them
This commit is contained in:
parent
711e6eabd0
commit
f28f21b061
@ -47,6 +47,7 @@ public class GenshinScene {
|
|||||||
|
|
||||||
private final Set<SpawnDataEntry> spawnedEntities;
|
private final Set<SpawnDataEntry> spawnedEntities;
|
||||||
private final Set<SpawnDataEntry> deadSpawnedEntities;
|
private final Set<SpawnDataEntry> deadSpawnedEntities;
|
||||||
|
private boolean dontDestroyWhenEmpty;
|
||||||
|
|
||||||
private int time;
|
private int time;
|
||||||
private ClimateType climate;
|
private ClimateType climate;
|
||||||
@ -121,6 +122,14 @@ public class GenshinScene {
|
|||||||
this.weather = weather;
|
this.weather = weather;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean dontDestroyWhenEmpty() {
|
||||||
|
return dontDestroyWhenEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDontDestroyWhenEmpty(boolean dontDestroyWhenEmpty) {
|
||||||
|
this.dontDestroyWhenEmpty = dontDestroyWhenEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
public Set<SpawnDataEntry> getSpawnedEntities() {
|
public Set<SpawnDataEntry> getSpawnedEntities() {
|
||||||
return spawnedEntities;
|
return spawnedEntities;
|
||||||
}
|
}
|
||||||
@ -166,7 +175,7 @@ public class GenshinScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deregister scene if not in use
|
// Deregister scene if not in use
|
||||||
if (this.getEntities().size() <= 0) {
|
if (this.getEntities().size() <= 0 && !this.dontDestroyWhenEmpty()) {
|
||||||
this.getWorld().deregisterScene(this);
|
this.getWorld().deregisterScene(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,19 +212,29 @@ public class World implements Iterable<GenshinPlayer> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer oldSceneId = null;
|
GenshinScene oldScene = null;
|
||||||
|
|
||||||
if (player.getScene() != null) {
|
if (player.getScene() != null) {
|
||||||
oldSceneId = player.getScene().getId();
|
oldScene = player.getScene();
|
||||||
player.getScene().removePlayer(player);
|
|
||||||
|
// Dont deregister scenes if the player is going to tp back into them
|
||||||
|
if (oldScene.getId() == sceneId) {
|
||||||
|
oldScene.setDontDestroyWhenEmpty(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
oldScene.removePlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
GenshinScene scene = this.getSceneById(sceneId);
|
GenshinScene newScene = this.getSceneById(sceneId);
|
||||||
scene.addPlayer(player);
|
newScene.addPlayer(player);
|
||||||
player.getPos().set(pos);
|
player.getPos().set(pos);
|
||||||
|
|
||||||
|
if (oldScene != null) {
|
||||||
|
oldScene.setDontDestroyWhenEmpty(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Teleport packet
|
// Teleport packet
|
||||||
if (oldSceneId.equals(sceneId)) {
|
if (oldScene == newScene) {
|
||||||
player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterType.EnterGoto, EnterReason.TransPoint, sceneId, pos));
|
player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterType.EnterGoto, EnterReason.TransPoint, sceneId, pos));
|
||||||
} else {
|
} else {
|
||||||
player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterType.EnterJump, EnterReason.TransPoint, sceneId, pos));
|
player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterType.EnterJump, EnterReason.TransPoint, sceneId, pos));
|
||||||
|
Loading…
Reference in New Issue
Block a user