diff --git a/src/main/java/emu/lunarcore/GameConstants.java b/src/main/java/emu/lunarcore/GameConstants.java index 8aa0f9742..ef3a2cc3d 100644 --- a/src/main/java/emu/lunarcore/GameConstants.java +++ b/src/main/java/emu/lunarcore/GameConstants.java @@ -14,6 +14,7 @@ public class GameConstants { // Game public static final String DEFAULT_NAME = "A Nameless"; public static final int[] DEFAULT_HEAD_ICONS = {208001, 208002}; + public static final int DEFAULT_WORLD_ID = 101; public static final int TRAILBLAZER_AVATAR_ID = 8001; public static final int MAX_TRAILBLAZER_LEVEL = 70; public static final int[] WORLD_LEVEL_UPGRADES = {0, 20, 30, 40, 50, 60, 65}; diff --git a/src/main/java/emu/lunarcore/game/player/Player.java b/src/main/java/emu/lunarcore/game/player/Player.java index f91eb94a8..f51b929b5 100644 --- a/src/main/java/emu/lunarcore/game/player/Player.java +++ b/src/main/java/emu/lunarcore/game/player/Player.java @@ -112,6 +112,7 @@ public class Player implements Tickable { private int planeId; private int floorId; private int entryId; + private int worldId; private long lastActiveTime; @@ -800,6 +801,11 @@ public boolean loadScene(int planeId, int floorId, int entryId, Position pos, Po nextScene = new Scene(this, planeExcel, floorId); } + // Set world id + if (planeExcel.getPlaneType() == PlaneType.Town || planeExcel.getPlaneType() == PlaneType.Maze) { + this.worldId = planeExcel.getWorldID(); + } + // Set player position this.getPos().set(pos); this.getRot().set(rot); @@ -918,6 +924,11 @@ public void onLogin() { this.challengeInstance = null; } + // Set default world id if we don't have it + if (this.worldId == 0) { + this.worldId = GameConstants.DEFAULT_WORLD_ID; + } + // Unstuck check, dont load player into raid scenes MazePlaneExcel planeExcel = GameData.getMazePlaneExcelMap().get(planeId); if (planeExcel == null || planeExcel.getPlaneType().getVal() >= PlaneType.Raid.getVal()) { diff --git a/src/main/java/emu/lunarcore/game/scene/Scene.java b/src/main/java/emu/lunarcore/game/scene/Scene.java index bb5d5b856..b376c374e 100644 --- a/src/main/java/emu/lunarcore/game/scene/Scene.java +++ b/src/main/java/emu/lunarcore/game/scene/Scene.java @@ -39,6 +39,7 @@ public class Scene implements Tickable { private final int planeId; private final int floorId; private int entryId; + private int worldId; @Setter private int leaveEntryId; private int lastEntityId = 0; @@ -72,6 +73,13 @@ public Scene(Player player, MazePlaneExcel excel, int floorId) { this.healingSprings = new ObjectArrayList<>(); this.triggers = new ObjectArrayList<>(); + // Set world id + if (this.getExcel().getPlaneType() == PlaneType.Train) { + this.worldId = player.getWorldId(); + } else { + this.worldId = this.getExcel().getWorldID(); + } + // Use singleton to avoid allocating memory for a new entity loader everytime we create a scene this.entityLoader = getExcel().getPlaneType().getSceneEntityLoader(); @@ -391,10 +399,10 @@ public void onBattleStart(Battle battle) { public synchronized SceneInfo toProto() { // Set loaded flag this.loaded = true; - + // Proto var proto = SceneInfo.newInstance() - .setWorldId(this.getExcel().getWorldID()) + .setWorldId(this.getWorldId()) .setGameModeType(this.getExcel().getPlaneType().getVal()) .setPlaneId(this.getPlaneId()) .setFloorId(this.getFloorId())