feat: super raw command to get block pos of cursor
This commit is contained in:
parent
5f5005fb3a
commit
10cbb3bd83
1 changed files with 46 additions and 0 deletions
46
src/main/java/ftbsc/bscv/commands/Cursor.java
Normal file
46
src/main/java/ftbsc/bscv/commands/Cursor.java
Normal 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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue