use of com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException in project Create by Creators-of-Create.
the class HighlightCommand method highlightAssemblyExceptionFor.
private static int highlightAssemblyExceptionFor(ServerPlayer player, CommandSourceStack source) {
double distance = player.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue();
Vec3 start = player.getEyePosition(1);
Vec3 look = player.getViewVector(1);
Vec3 end = start.add(look.x * distance, look.y * distance, look.z * distance);
Level world = player.level;
BlockHitResult ray = world.clip(new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player));
if (ray.getType() == HitResult.Type.MISS) {
sendMissMessage(source);
return 0;
}
BlockPos pos = ray.getBlockPos();
BlockEntity te = world.getBlockEntity(pos);
if (!(te instanceof IDisplayAssemblyExceptions)) {
sendMissMessage(source);
return 0;
}
IDisplayAssemblyExceptions display = (IDisplayAssemblyExceptions) te;
AssemblyException exception = display.getLastAssemblyException();
if (exception == null) {
sendMissMessage(source);
return 0;
}
if (!exception.hasPosition()) {
source.sendSuccess(new TextComponent("Can't highlight a specific position for this issue"), true);
return Command.SINGLE_SUCCESS;
}
BlockPos p = exception.getPosition();
String command = "/create highlight " + p.getX() + " " + p.getY() + " " + p.getZ();
return player.server.getCommands().performCommand(source, command);
}
Aggregations