aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/ftbsc/bscv/commands/Cursor.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/bscv/commands/Cursor.java b/src/main/java/ftbsc/bscv/commands/Cursor.java
new file mode 100644
index 0000000..49a93aa
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/commands/Cursor.java
@@ -0,0 +1,46 @@
+package ftbsc.bscv.commands;
+
+import com.google.auto.service.AutoService;
+import com.mojang.brigadier.builder.LiteralArgumentBuilder;
+
+import ftbsc.bscv.api.ILoadable;
+import net.minecraft.command.CommandSource;
+import net.minecraft.command.Commands;
+import net.minecraft.util.Direction;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.BlockRayTraceResult;
+
+import static ftbsc.bscv.Boscovicino.log;
+
+@AutoService(ILoadable.class)
+public class Cursor extends AbstractCommand {
+
+ public LiteralArgumentBuilder<CommandSource> register(LiteralArgumentBuilder<CommandSource> builder) {
+ return builder
+ .then(
+ Commands.literal("pos")
+ .executes(ctx -> {
+ switch (MC.hitResult.getType()) {
+ case BLOCK:
+ BlockRayTraceResult result = (BlockRayTraceResult) MC.hitResult;
+ Direction dir = result.getDirection();
+ BlockPos pos =result.getBlockPos();
+ log("Block @ %s (%s)", pos.toString(), dir.toString());
+ return 1;
+ case ENTITY:
+ log("Entity @ %s", MC.hitResult.getLocation().toString());
+ return 1;
+ default:
+ case MISS:
+ log("[!] nothing under cursor");
+ return 0;
+ }
+ })
+ )
+ .executes(ctx -> {
+ log("[!] no domain specified");
+ return 0;
+ });
+ }
+
+}