Teleport a player to block some dynamically

I did this for him and it’s working.

    @Listener
    public void onClick(InteractBlockEvent.Secondary event){
        Player player = event.getCause().first(Player.class).get();
        BlockRay optHit = BlockRay.from(player).filter(BlockRay.allFilter()).build();
        BlockState state = null;

        while(optHit.hasNext() && state == null){
            BlockRayHit ray = optHit.next();
            Vector3d lookPos = ray.getBlockPosition().toDouble();
            BlockState blockState = player.getWorld().getBlock(lookPos.toInt());

            state = !blockState.getType().equals(BlockTypes.AIR)?blockState:null;
        }

        System.out.println(state.getType());
    }

Ce n’est pas encore parfait:

Googole trad:
It’s still not perfect^^:
https:https://forums-cdn.spongepowered.org/uploads/default/optimized/2X/2/2b995d83348c1d3736ad693f07b4abe4644fcda5_1_690x412.jpg

https:https://forums-cdn.spongepowered.org/uploads/default/optimized/2X/9/94812ee53edfd96311aebd713e8aa94afbf001ae_1_690x412.jpg
.

Unfortunately, it doesn’t work properly with blecks that don’t take up their full block space. It assumes all blocks take up their full block space.