don't invent start position if you don't have one yet

This commit is contained in:
Player Name 2026-07-21 15:48:35 +02:00
parent 12d7f526ac
commit 9b5ffa2255
3 changed files with 11 additions and 7 deletions

View file

@ -214,7 +214,7 @@ public class NPC extends Entity {
getProperties().setSpawnLocation(getLocation());
initConfig();
Repository.getNpcs().add(this);
RegionManager.move(this, ServerConstants.START_LOCATION, location);
RegionManager.move(this, null, location);
if (getLocation().getRegion().isActive()) {
Repository.addRenderableNPC(this);
}

View file

@ -130,7 +130,7 @@ public final class LoginConfiguration {
Repository.getLobbyPlayers().remove(player);
player.setPlaying(true);
UpdateSequence.getRenderablePlayers().add(player);
RegionManager.move(player, ServerConstants.START_LOCATION, player.getLocation());
RegionManager.move(player, null, player.getLocation());
player.getMusicPlayer().init();
player.updateAppearance();
player.getPlayerFlags().setUpdateSceneGraph(true);

View file

@ -378,17 +378,21 @@ object RegionManager {
* @param entity The entity.
*/
@JvmStatic
fun move(entity: Entity, src: Location, dst: Location) {
if (src.chunk != dst.chunk) {
fun move(entity: Entity, src: Location?, dst: Location) {
if (src?.chunk != dst.chunk) {
when (entity) {
is Player -> {
src.chunk.removePlayer(entity)
src.region.decrementViewAmount()
if (src != null) {
src.chunk.removePlayer(entity)
src.region.decrementViewAmount()
}
dst.chunk.addPlayer(entity)
dst.region.incrementViewAmount()
}
is NPC -> {
src.chunk.remove(entity)
if (src != null) {
src.chunk.remove(entity)
}
dst.chunk.add(entity)
}
else -> {