3131import net .minecraft .block .state .BlockFaceShape ;
3232import net .minecraft .block .state .BlockStateContainer ;
3333import net .minecraft .block .state .IBlockState ;
34+ import net .minecraft .client .Minecraft ;
3435import net .minecraft .client .renderer .texture .TextureAtlasSprite ;
3536import net .minecraft .client .resources .I18n ;
3637import net .minecraft .client .util .ITooltipFlag ;
5859import net .minecraftforge .fml .relauncher .Side ;
5960import net .minecraftforge .fml .relauncher .SideOnly ;
6061
61- import codechicken .lib .raytracer .RayTracer ;
6262import it .unimi .dsi .fastutil .objects .Object2ObjectOpenHashMap ;
6363import org .apache .commons .lang3 .tuple .Pair ;
6464import org .jetbrains .annotations .NotNull ;
@@ -509,7 +509,17 @@ public RayTraceResult collisionRayTrace(@NotNull IBlockState blockState, @NotNul
509509
510510 public @ Nullable RayTraceAABB collisionRayTrace (@ NotNull EntityPlayer player ,
511511 @ NotNull World world , @ NotNull BlockPos pos ) {
512- return collisionRayTrace (player , world , pos , RayTracer .getStartVec (player ), RayTracer .getEndVec (player ));
512+ Vec3d vec3d = player .getPositionEyes (0 );
513+ Vec3d vec3d1 = player .getLook (0 );
514+ double blockReachDistance ;
515+ if (world .isRemote ) {
516+ blockReachDistance = Minecraft .getMinecraft ().playerController .getBlockReachDistance ();
517+ } else {
518+ blockReachDistance = player .getEntityAttribute (EntityPlayer .REACH_DISTANCE ).getAttributeValue ();
519+ }
520+ Vec3d vec3d2 = vec3d .add (vec3d1 .x * blockReachDistance , vec3d1 .y * blockReachDistance ,
521+ vec3d1 .z * blockReachDistance );
522+ return collisionRayTrace (player , world , pos , vec3d , vec3d2 );
513523 }
514524
515525 public @ Nullable RayTraceAABB collisionRayTrace (@ Nullable EntityPlayer player ,
@@ -519,17 +529,14 @@ public RayTraceResult collisionRayTrace(@NotNull IBlockState blockState, @NotNul
519529 return RayTraceAABB .of (rayTrace (pos , start , end , FULL_BLOCK_AABB ), FULL_BLOCK_AABB );
520530 }
521531 PipeTileEntity tile = getTileEntity (worldIn , pos );
522- if (tile == null ) {
532+ if (tile == null || tile . getFrameMaterial () != null ) {
523533 return RayTraceAABB .of (rayTrace (pos , start , end , FULL_BLOCK_AABB ), FULL_BLOCK_AABB );
524534 }
535+ List <AxisAlignedBB > bbs = getStructure ().getPipeBoxes (tile );
536+ tile .getCoverBoxes (bbs ::add );
525537 RayTraceResult min = null ;
526538 AxisAlignedBB minbb = null ;
527539 double minDistSqrd = Double .MAX_VALUE ;
528- List <AxisAlignedBB > bbs = getStructure ().getPipeBoxes (tile );
529- tile .getCoverBoxes (bbs ::add );
530- if (tile .getFrameMaterial () != null ) {
531- bbs .add (FULL_BLOCK_AABB );
532- }
533540 for (AxisAlignedBB aabb : bbs ) {
534541 RayTraceResult result = rayTrace (pos , start , end , aabb );
535542 if (result == null ) continue ;
0 commit comments