From 2994d3061c02186e382fbc71b6ae8c1a8e76ce11 Mon Sep 17 00:00:00 2001 From: Antonio Cheong Date: Wed, 17 Jan 2024 05:55:58 +0000 Subject: [PATCH] fix end city locator and include distance in notification --- build.gradle | 8 ++++---- .../java/anticope/rejects/commands/LocateCommand.java | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index c85d55f..afdc612 100644 --- a/build.gradle +++ b/build.gradle @@ -25,10 +25,10 @@ configurations { dependencies { // This will make it work on most platforms. It automatically chooses the right dependencies at runtime. - extraLibs('dev.duti.acheong:cubiomes:1.22.1') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.1:linux64') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.1:osx') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.1:windows64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.2') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.2:linux64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.2:osx') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.2:windows64') { transitive = false } // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_version}:v2" diff --git a/src/main/java/anticope/rejects/commands/LocateCommand.java b/src/main/java/anticope/rejects/commands/LocateCommand.java index 2533133..0fb3e0e 100644 --- a/src/main/java/anticope/rejects/commands/LocateCommand.java +++ b/src/main/java/anticope/rejects/commands/LocateCommand.java @@ -77,12 +77,17 @@ public void build(LiteralArgumentBuilder builder) { } if (pos != null) { + // Calculate distance + int distance = (int) Math.hypot(pos.x - playerPos.getX(), pos.z - playerPos.getZ()); MutableText text = Text.literal(String.format( "%s located at ", Utils.nameToTitle(feature.toString().replaceAll("_", "-")))); Vec3d coords = new Vec3d(pos.x, 0, pos.z); text.append(ChatUtils.formatCoords(coords)); text.append("."); + if (distance > 0) { + text.append(String.format(" (%d blocks away)", distance)); + } info(text); return SINGLE_SUCCESS; }