|
|
|
@@ -18,7 +18,9 @@ import static net.minecraft.server.command.CommandManager.argument;
|
|
|
|
|
import static net.minecraft.server.command.CommandManager.literal;
|
|
|
|
|
|
|
|
|
|
public class CommandRegister {
|
|
|
|
|
final static long WorldBorder = (long) 2.9e7;
|
|
|
|
|
// https://zh.minecraft.wiki/w/%E4%B8%96%E7%95%8C%E7%95%8C%E9%99%90
|
|
|
|
|
// https://minecraft.wiki/w/World_boundary
|
|
|
|
|
final static long WorldBoundary = (long) 2.9e7;
|
|
|
|
|
static byte Retry = 0;
|
|
|
|
|
static byte PermissionLevel = 2;
|
|
|
|
|
public static void Register(String Name){
|
|
|
|
@@ -166,9 +168,9 @@ public class CommandRegister {
|
|
|
|
|
static int execute_command(ServerCommandSource Source, @Nullable Long Radius, @Nullable Entity Player, @Nullable Vec3d Origin){
|
|
|
|
|
Entity entity = Player == null ? Source.getPlayer() : Player;
|
|
|
|
|
if (entity == null) {
|
|
|
|
|
Source.sendFeedback(()->{ return Text.translatable("error.twd.rtp.not_player"); }, true);
|
|
|
|
|
Source.sendFeedback(Text.translatable("error.twd.rtp.not_player"), true);
|
|
|
|
|
return -1;}
|
|
|
|
|
if (Radius == null){Radius = WorldBorder - (long) 1e4;}
|
|
|
|
|
if (Radius == null){Radius = WorldBoundary - (long) 1e4;}
|
|
|
|
|
Radius = Math.abs(Radius);
|
|
|
|
|
long Coordinate_X;
|
|
|
|
|
long Coordinate_Z;
|
|
|
|
@@ -193,17 +195,17 @@ public class CommandRegister {
|
|
|
|
|
// Coordinate_Y++;}
|
|
|
|
|
Coordinate_Y++;
|
|
|
|
|
Vec3d Coordinate = new Vec3d(Coordinate_X, Coordinate_Y, Coordinate_Z);
|
|
|
|
|
if (Radius == WorldBorder && Retry < 126 && entity.getPos().distanceTo(Coordinate) < 1e5){
|
|
|
|
|
if (Radius == WorldBoundary && Retry < 126 && entity.getPos().distanceTo(Coordinate) < 1e5){
|
|
|
|
|
Retry++;
|
|
|
|
|
execute_command(Source, Radius,null, Origin);
|
|
|
|
|
return 0;}
|
|
|
|
|
if (Retry >= 126){
|
|
|
|
|
Source.sendFeedback(()->{ return Text.translatable("warning.twd.rtp.retry"); }, true);}
|
|
|
|
|
Source.sendFeedback(Text.translatable("warning.twd.rtp.retry"), true);}
|
|
|
|
|
entity.teleport(Coordinate_X + 0.5, Coordinate_Y, Coordinate_Z + 0.5);
|
|
|
|
|
final long FinalCoordinate_X = Coordinate_X;
|
|
|
|
|
final int FinalCoordinate_Y = Coordinate_Y;
|
|
|
|
|
final long FinalCoordinate_Z = Coordinate_Z;
|
|
|
|
|
Source.sendFeedback(()->{ return Text.translatable("info.twd.rtp.success", entity.getName(), FinalCoordinate_X, FinalCoordinate_Y, FinalCoordinate_Z); },true);
|
|
|
|
|
Source.sendFeedback(Text.translatable("info.twd.rtp.success", entity.getName(), FinalCoordinate_X, FinalCoordinate_Y, FinalCoordinate_Z),true);
|
|
|
|
|
return 0;}
|
|
|
|
|
static int execute_command_origin(ServerCommandSource Source, @Nullable Long Radius, @Nullable Entity Player, Entity Origin){
|
|
|
|
|
return execute_command(Source, Radius, Player, Origin.getPos());}
|
|
|
|
|