Class RenderDistanceHelper

java.lang.Object
com.hbm_m.client.render.RenderDistanceHelper

public final class RenderDistanceHelper extends Object
Shared utility for distance-based LOD and fade-out calculations used by all BER renderers. Centralizes the distance check and fade factor math so every renderer behaves identically.

The fade zone spans the last 16 blocks (1 chunk) before the cutoff distance. Within this zone, computeFade(net.minecraft.core.BlockPos, double) returns a value in (0, 1] that renderers multiply into their alpha / color to smoothly dissolve the part instead of popping it out abruptly.

  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    computeAnimatedFade(net.minecraft.core.BlockPos blockPos)
    Computes a fade factor for animated parts at the given position.
    static float
    computeAnimatedFade(net.minecraft.world.level.block.entity.BlockEntity blockEntity)
    Safely computes animated fade factor, bypassing fading entirely on Create contraptions.
    static float
    computeFade(net.minecraft.core.BlockPos blockPos, double maxBlocks)
    Core fade calculation.
    static float
    computeFade(net.minecraft.world.level.block.entity.BlockEntity blockEntity, double maxBlocks)
    Safely computes fade factor, bypassing fading entirely on Create contraptions.
    static float
    computeStaticFade(net.minecraft.core.BlockPos blockPos)
    Computes a fade factor for static parts at the given position.
    static float
    computeStaticFade(net.minecraft.world.level.block.entity.BlockEntity blockEntity)
    Safely computes static fade factor, bypassing fading entirely on Create contraptions.
    static double
    distanceSqToCamera(net.minecraft.core.BlockPos blockPos)
    Computes the squared distance from the camera to the block center.
    static double
    Returns the maximum render distance for animated/dynamic parts in blocks.
    static double
    Squared camera distance threshold for full 8-corner LightSampleCache sampling.
    static double
    Returns the maximum render distance for static parts in blocks.
    static int
    Converts a BER view distance config (in chunks) to blocks, matching BlockEntityRenderer.getViewDistance().
    static boolean
    shouldSkipAnimation(net.minecraft.core.BlockPos blockPos)
    Whether the animated parts should be completely skipped (beyond cutoff).
    static boolean
    shouldSkipAnimation(net.minecraft.world.level.block.entity.BlockEntity blockEntity)
    Safely checks if animation should be skipped, bypassing the check on Create contraptions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • distanceSqToCamera

      public static double distanceSqToCamera(net.minecraft.core.BlockPos blockPos)
      Computes the squared distance from the camera to the block center.
    • getAnimatedDistanceBlocks

      public static double getAnimatedDistanceBlocks()
      Returns the maximum render distance for animated/dynamic parts in blocks.
    • getStaticDistanceBlocks

      public static double getStaticDistanceBlocks()
      Returns the maximum render distance for static parts in blocks.
    • shouldSkipAnimation

      public static boolean shouldSkipAnimation(net.minecraft.core.BlockPos blockPos)
      Whether the animated parts should be completely skipped (beyond cutoff).
    • shouldSkipAnimation

      public static boolean shouldSkipAnimation(net.minecraft.world.level.block.entity.BlockEntity blockEntity)
      Safely checks if animation should be skipped, bypassing the check on Create contraptions.
    • computeAnimatedFade

      public static float computeAnimatedFade(net.minecraft.core.BlockPos blockPos)
      Computes a fade factor for animated parts at the given position.
    • computeAnimatedFade

      public static float computeAnimatedFade(net.minecraft.world.level.block.entity.BlockEntity blockEntity)
      Safely computes animated fade factor, bypassing fading entirely on Create contraptions.
    • computeStaticFade

      public static float computeStaticFade(net.minecraft.core.BlockPos blockPos)
      Computes a fade factor for static parts at the given position.
    • computeStaticFade

      public static float computeStaticFade(net.minecraft.world.level.block.entity.BlockEntity blockEntity)
      Safely computes static fade factor, bypassing fading entirely on Create contraptions.
    • computeFade

      public static float computeFade(net.minecraft.core.BlockPos blockPos, double maxBlocks)
      Core fade calculation.
      Parameters:
      blockPos - block to measure distance to
      maxBlocks - cutoff distance in blocks
      Returns:
      fade factor in [0, 1], or -1 if fully beyond cutoff
    • computeFade

      public static float computeFade(net.minecraft.world.level.block.entity.BlockEntity blockEntity, double maxBlocks)
      Safely computes fade factor, bypassing fading entirely on Create contraptions.
    • getStaticViewDistanceBlocks

      public static int getStaticViewDistanceBlocks()
      Converts a BER view distance config (in chunks) to blocks, matching BlockEntityRenderer.getViewDistance().
    • getLightCornerDetailDistanceSq

      public static double getLightCornerDetailDistanceSq()
      Squared camera distance threshold for full 8-corner LightSampleCache sampling. Beyond this, callers should use uniform corner UV from vanilla packed light.