feat: super raw command to get block pos of cursor

This commit is contained in:
əlemi 2023-03-18 22:08:10 +01:00
parent 5f5005fb3a
commit 10cbb3bd83
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -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;
});
}
}