Topic category: Help with Minecraft modding (Java Edition)
i know that for raycasting blocks you use this code:
double rayCastDistance = 20;
RayTraceResult result = player.pick(rayCastDistance ,0.0F,false);
if(result.getType() == RayTraceResult.Type.BLOCK)
{
BlockPos lookPos = ((BlockRayTraceResult) result).getPos(); //This changes too but i know what goes here
BlockState state = world.getBlockState(lookPos); //and here
}
and for entities you change .Type.BLOCK to .Type.ENTITY and player.pick to Minecraft.getInstance().objectMouseOver but that doesnt let me change the ray cast distance, objectMouseOver only works a few meters away from the entity you want to raycast, but i want to make you can raycast an entity 50 blocks away or anything i want
how can i do that? (raycast the entity im looking at)
PD: code or procedures is ok