This commit is contained in:
@@ -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;
|
return Math.round(value * 10.0) / 10.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package ciomek.quetzal.commands;
|
package ciomek.quetzal.commands;
|
||||||
|
|
||||||
import ciomek.quetzal.IWorldUtils;
|
import ciomek.quetzal.IWorldUtils;
|
||||||
|
import ciomek.quetzal.Utils;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
@@ -92,14 +93,14 @@ public class HomeCommand implements CommandManager.CommandRegistry, ModInitializ
|
|||||||
|
|
||||||
double[] home = homes.get(player.username);
|
double[] home = homes.get(player.username);
|
||||||
|
|
||||||
double startX = round1(player.x);
|
double startX = Utils.round1(player.x);
|
||||||
double startY = round1(player.y);
|
double startY = Utils.round1(player.y);
|
||||||
double startZ = round1(player.z);
|
double startZ = Utils.round1(player.z);
|
||||||
|
|
||||||
player.sendMessage("Teleporting home. Don't move for 5 seconds...");
|
player.sendMessage("Teleporting home. Don't move for 5 seconds...");
|
||||||
|
|
||||||
worldUtils.addTickCallback(100, (w) -> {
|
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.");
|
player.sendMessage("Teleport cancelled because you moved.");
|
||||||
return;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user