1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package ftbsc.bscv.commands;
import com.google.auto.service.AutoService;
import com.mojang.brigadier.arguments.DoubleArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import ftbsc.bscv.api.ILoadable;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import static ftbsc.bscv.Boscovicino.log;
@AutoService(ILoadable.class)
public class Teleport extends AbstractCommand {
@Override
public String getName() { return "tp"; }
public LiteralArgumentBuilder<CommandSource> register(LiteralArgumentBuilder<CommandSource> builder) {
return builder
.then(
Commands.literal("up")
.then(
Commands.argument("distance", DoubleArgumentType.doubleArg())
.executes( ctx -> {
if(MC.player == null)
return 0;
double distance = ctx.getArgument("distance", Double.class);
MC.player.setPos(
MC.player.position().x,
MC.player.position().y + distance,
MC.player.position().z
);
log(String.format("blinked up %.1f blocks", distance));
return 1;
})
)
)
.then(
Commands.argument("x", DoubleArgumentType.doubleArg())
.then(
Commands.argument("y", DoubleArgumentType.doubleArg())
.then(
Commands.argument("z", DoubleArgumentType.doubleArg())
.executes( ctx -> {
if(MC.player == null)
return 0;
double x = ctx.getArgument("x", Double.class);
double y = ctx.getArgument("y", Double.class);
double z = ctx.getArgument("z", Double.class);
MC.player.setPos(x, y, z);
log(String.format("blinked to X%.0f | Z%.0f", x, z));
return 1;
})
)
)
)
.executes(ctx -> {
log("no args specified");
return 0;
});
}
}
|