diff --git a/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonData.java b/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonData.java index 4e42f1b8e..b63519921 100644 --- a/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonData.java +++ b/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonData.java @@ -6,6 +6,9 @@ import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.excels.RewardPreviewData; import emu.grasscutter.game.dungeons.enums.*; import java.util.List; + +import emu.grasscutter.scripts.data.SceneMeta; +import emu.grasscutter.utils.Position; import lombok.Getter; @ResourceType(name = "DungeonExcelConfigData.json") @@ -62,6 +65,20 @@ public class DungeonData extends GameResource { return involveType; } + /** + * @return The position of the player when they enter the dungeon. + */ + public Position getStartPosition() { + return SceneMeta.of(this.getSceneId()).config.born_pos; + } + + /** + * @return The rotation of the player when they enter the dungeon. + */ + public Position getStartRotation() { + return SceneMeta.of(this.getSceneId()).config.born_rot; + } + @Override public void onLoad() { if (this.passRewardPreviewID > 0) { diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index a303891a1..d31c8e361 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -279,17 +279,25 @@ public class World implements Iterable { val sceneData = GameData.getSceneDataMap().get(sceneId); if (dungeonData != null) { - teleportProps.enterType(EnterType.ENTER_TYPE_DUNGEON).enterReason(EnterReason.DungeonEnter); + teleportProps.teleportTo(dungeonData.getStartPosition()) + .teleportRot(dungeonData.getStartRotation()); + teleportProps.enterType(EnterType.ENTER_TYPE_DUNGEON) + .enterReason(EnterReason.DungeonEnter); } else if (player.getSceneId() == sceneId) { teleportProps.enterType(EnterType.ENTER_TYPE_GOTO); } else if (sceneData != null && sceneData.getSceneType() == SceneType.SCENE_HOME_WORLD) { // Home teleportProps.enterType(EnterType.ENTER_TYPE_SELF_HOME).enterReason(EnterReason.EnterHome); } + return transferPlayerToScene(player, teleportProps.build()); } public boolean transferPlayerToScene(Player player, TeleportProperties teleportProperties) { + // Check if the teleport properties are valid. + if (teleportProperties.getTeleportTo() == null) + teleportProperties.setTeleportTo(player.getPosition()); + // Call player teleport event. PlayerTeleportEvent event = new PlayerTeleportEvent(player, teleportProperties, player.getPosition());