summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-03-04 01:31:12 +0100
committer alemi <me@alemi.dev>2023-03-04 01:31:12 +0100
commita71402637edf6ca599da1db9e323e87fb8e245e8 (patch)
treeb60a1e872441219e6cdc40edb27cac103c1d2985
parent8813dda003cea6286dcfdc94c6c5a22b0cbe8b01 (diff)
feat: added basic tp command
-rw-r--r--src/main/java/ftbsc/bscv/commands/Teleport.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/bscv/commands/Teleport.java b/src/main/java/ftbsc/bscv/commands/Teleport.java
new file mode 100644
index 0000000..698d94c
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/commands/Teleport.java
@@ -0,0 +1,60 @@
+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 -> {
+ 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 -> {
+ 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;
+ });
+ }
+
+}