From 3619df118b35f6ce0a977a33f4c65dfb81b08867 Mon Sep 17 00:00:00 2001 From: ciomek Date: Mon, 16 Mar 2026 21:02:06 +0100 Subject: [PATCH] Refactor --- src/main/java/ciomek/quetzal/Utils.java | 2 +- .../java/ciomek/quetzal/commands/HomeCommand.java | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/ciomek/quetzal/Utils.java b/src/main/java/ciomek/quetzal/Utils.java index 23a9b44..3d2fd63 100644 --- a/src/main/java/ciomek/quetzal/Utils.java +++ b/src/main/java/ciomek/quetzal/Utils.java @@ -26,7 +26,7 @@ public class Utils { }); } - private static double round1(double value) { + public static double round1(double value) { return Math.round(value * 10.0) / 10.0; } } diff --git a/src/main/java/ciomek/quetzal/commands/HomeCommand.java b/src/main/java/ciomek/quetzal/commands/HomeCommand.java index 42fd513..4c127bf 100644 --- a/src/main/java/ciomek/quetzal/commands/HomeCommand.java +++ b/src/main/java/ciomek/quetzal/commands/HomeCommand.java @@ -1,6 +1,7 @@ package ciomek.quetzal.commands; import ciomek.quetzal.IWorldUtils; +import ciomek.quetzal.Utils; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.mojang.brigadier.CommandDispatcher; @@ -92,14 +93,14 @@ public class HomeCommand implements CommandManager.CommandRegistry, ModInitializ double[] home = homes.get(player.username); - double startX = round1(player.x); - double startY = round1(player.y); - double startZ = round1(player.z); + double startX = Utils.round1(player.x); + double startY = Utils.round1(player.y); + double startZ = Utils.round1(player.z); player.sendMessage("Teleporting home. Don't move for 5 seconds..."); worldUtils.addTickCallback(100, (w) -> { - if (round1(player.x) != startX || round1(player.y) != startY || round1(player.z) != startZ) { + if (Utils.round1(player.x) != startX || Utils.round1(player.y) != startY || Utils.round1(player.z) != startZ) { player.sendMessage("Teleport cancelled because you moved."); return; } @@ -112,8 +113,4 @@ public class HomeCommand implements CommandManager.CommandRegistry, ModInitializ }) ); } - - private double round1(double value) { - return Math.round(value * 10.0) / 10.0; - } }