From 9e523da18eebf9eedddbbbf6ad8f9ec67c3e2bd8 Mon Sep 17 00:00:00 2001 From: Yazawazi <47273265+Yazawazi@users.noreply.github.com> Date: Sun, 24 Apr 2022 05:20:59 +0800 Subject: [PATCH] tp with relative coordinates --- .../command/commands/TelePortCommand.java | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/TelePortCommand.java b/src/main/java/emu/grasscutter/command/commands/TelePortCommand.java index 1a9e4f87a..84848afa5 100644 --- a/src/main/java/emu/grasscutter/command/commands/TelePortCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/TelePortCommand.java @@ -24,9 +24,36 @@ public class TelePortCommand implements CommandHandler { } try { - float x = Float.parseFloat(args.get(0)); - float y = Float.parseFloat(args.get(1)); - float z = Float.parseFloat(args.get(2)); + float x = 0f; + float y = 0f; + float z = 0f; + if (args.get(0).contains("~")) { + if (args.get(0).equals("~")) { + x = sender.getPos().getX(); + } else { + x = Float.parseFloat(args.get(0).replace("~", "")) + sender.getPos().getX(); + } + } else { + x = Float.parseFloat(args.get(0)); + } + if (args.get(1).contains("~")) { + if (args.get(1).equals("~")) { + y = sender.getPos().getY(); + } else { + y = Float.parseFloat(args.get(1).replace("~", "")) + sender.getPos().getY(); + } + } else { + y = Float.parseFloat(args.get(1)); + } + if (args.get(2).contains("~")) { + if (args.get(2).equals("~")) { + z = sender.getPos().getZ(); + } else { + z = Float.parseFloat(args.get(2).replace("~", "")) + sender.getPos().getZ(); + } + } else { + z = Float.parseFloat(args.get(2)); + } int sceneId = sender.getSceneId(); if (args.size() == 4){ sceneId = Integer.parseInt(args.get(3));