From 4f3112133c590763ec385c2db5aa91dd2fb1be84 Mon Sep 17 00:00:00 2001 From: Yazawazi <47273265+Yazawazi@users.noreply.github.com> Date: Sat, 14 May 2022 04:50:31 +0800 Subject: [PATCH] fix(serenitea pot): teleport & read born pos from lua --- .../emu/grasscutter/game/world/World.java | 5 ++ .../packet/recv/HandlerTryEnterHomeReq.java | 48 +++++-------------- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index 95356a15a..22048077d 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -268,6 +268,11 @@ public class World implements Iterable { } else if (oldScene == newScene) { enterType = EnterType.ENTER_GOTO; } + + // Home + if (2001 <= newScene.getId() && newScene.getId() <= 2004) { + enterType = EnterType.ENTER_SELF_HOME; + } // Teleport packet player.sendPacket(new PacketPlayerEnterSceneNotify(player, enterType, enterReason, sceneId, pos)); diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java index 3e78bcb3a..5df106df2 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java @@ -1,10 +1,12 @@ package emu.grasscutter.server.packet.recv; -import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.GameData; +import emu.grasscutter.game.world.Scene; import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.TryEnterHomeReqOuterClass; +import emu.grasscutter.scripts.data.SceneConfig; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.packet.send.PacketTryEnterHomeRsp; import emu.grasscutter.utils.Position; @@ -23,44 +25,16 @@ public class HandlerTryEnterHomeReq extends PacketHandler { return; } - // Hardcoded for now - switch (session.getPlayer().getCurrentRealmId()) { - case 1: - session.getPlayer().getWorld().transferPlayerToScene( - session.getPlayer(), - 2001, - new Position(839, 319, 137) - ); - break; + int realmId = 2000 + session.getPlayer().getCurrentRealmId(); - case 2: - session.getPlayer().getWorld().transferPlayerToScene( - session.getPlayer(), - 2002, - new Position(605, 444, 554) - ); - break; + Scene scene = session.getPlayer().getWorld().getSceneById(realmId); + Position pos = scene.getScriptManager().getConfig().born_pos; - case 3: - session.getPlayer().getWorld().transferPlayerToScene( - session.getPlayer(), - 2003, - new Position(511, 229, 605) - ); - break; - - case 4: - session.getPlayer().getWorld().transferPlayerToScene( - session.getPlayer(), - 2004, - new Position(239, 187, 536) - ); - break; - - default: - session.send(new PacketTryEnterHomeRsp()); - return; - } + session.getPlayer().getWorld().transferPlayerToScene( + session.getPlayer(), + realmId, + pos + ); session.send(new PacketTryEnterHomeRsp(req.getTargetUid()));