Refactor
All checks were successful
build / build (push) Successful in 3m43s

This commit is contained in:
2026-03-16 21:02:06 +01:00
parent 6e86c47bbb
commit 3619df118b
2 changed files with 6 additions and 9 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}