From be8867158c9fdfdb48e3537668584dab07c7f0dc Mon Sep 17 00:00:00 2001 From: Gugle Date: Mon, 28 Oct 2024 22:21:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BAloc=E3=80=81here=E3=80=81whereis?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=BB=E4=B8=96=E7=95=8C/=E4=B8=8B?= =?UTF-8?q?=E7=95=8C=E5=9D=90=E6=A0=87=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gugle/carpet/commands/HereCommand.java | 23 ++++++++++++++++--- .../gugle/carpet/commands/LocCommand.java | 23 +++++++++++++++++-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/main/java/dev/dubhe/gugle/carpet/commands/HereCommand.java b/src/main/java/dev/dubhe/gugle/carpet/commands/HereCommand.java index 8aadc3d..a5e8e3d 100644 --- a/src/main/java/dev/dubhe/gugle/carpet/commands/HereCommand.java +++ b/src/main/java/dev/dubhe/gugle/carpet/commands/HereCommand.java @@ -58,6 +58,23 @@ public static int execute(@NotNull CommandContext context) { ) .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(dimension.location().toString()))) ); + double scale = 0; + if (dimension == Level.NETHER) { + scale = 8; + } else if (dimension == Level.OVERWORLD) { + scale = 0.125; + } + MutableComponent toPos = Component.literal("[%.2f, %.2f, %.2f]".formatted(position.x * scale, position.y * scale, position.z * scale)).withStyle( + Style.EMPTY + .applyFormat( + dimension == Level.OVERWORLD ? + ChatFormatting.RED : + dimension == Level.NETHER ? + ChatFormatting.GREEN : + ChatFormatting.AQUA + ) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(dimension.location().toString()))) + ); MutableComponent addMap = Component.literal("[+X]").withStyle( Style.EMPTY .applyFormat(ChatFormatting.GREEN) @@ -74,8 +91,8 @@ public static int execute(@NotNull CommandContext context) { ) )) ); - return Component.literal("%s at".formatted(name)) - .append(" ").append(pos) - .append(" ").append(addMap); + MutableComponent component = Component.literal("%s at".formatted(name)).append(" ").append(pos); + if (scale > 0) component.append("->").append(toPos); + return component.append(" ").append(addMap); } } diff --git a/src/main/java/dev/dubhe/gugle/carpet/commands/LocCommand.java b/src/main/java/dev/dubhe/gugle/carpet/commands/LocCommand.java index ececc86..7d65e7c 100644 --- a/src/main/java/dev/dubhe/gugle/carpet/commands/LocCommand.java +++ b/src/main/java/dev/dubhe/gugle/carpet/commands/LocCommand.java @@ -187,6 +187,23 @@ public static int list(CommandContext context) { ) .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(locPoint.dimType.location().toString()))) ); + double scale = 0; + if (locPoint.dimType == Level.NETHER) { + scale = 8; + } else if (locPoint.dimType == Level.OVERWORLD) { + scale = 0.125; + } + MutableComponent toPos = Component.literal("[%.2f, %.2f, %.2f]".formatted(locPoint.x * scale, locPoint.y * scale, locPoint.z * scale)).withStyle( + Style.EMPTY + .applyFormat( + locPoint.dimType == Level.OVERWORLD ? + ChatFormatting.RED : + locPoint.dimType == Level.NETHER ? + ChatFormatting.GREEN : + ChatFormatting.AQUA + ) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(locPoint.dimType.location().toString()))) + ); MutableComponent addMap = Component.literal("[+X]").withStyle( Style.EMPTY .applyFormat(ChatFormatting.GREEN) @@ -208,8 +225,10 @@ public static int list(CommandContext context) { .applyFormat(ChatFormatting.RED) .withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/loc remove %s".formatted(locPoint.id))) ); - return Component.literal("▶ ").append(component) - .append(" ").append(pos) + MutableComponent component1 = Component.literal("▶ ").append(component) + .append(" ").append(pos); + if (scale > 0) component1.append("->").append(toPos); + return component1 .append(" ").append(addMap) .append(" ").append(remove); }