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 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).
    • computeAnimatedFade

      public static float computeAnimatedFade(net.minecraft.core.BlockPos blockPos)
      Computes a fade factor for animated parts at the given position.
      Returns:
      1.0 when fully visible, 0.0 when at/beyond cutoff, smooth transition in the last FADE_ZONE_BLOCKS before cutoff. Returns -1 if beyond cutoff (caller should skip rendering entirely).
    • computeStaticFade

      public static float computeStaticFade(net.minecraft.core.BlockPos blockPos)
      Computes a fade factor for static parts at the given position.
      Returns:
      1.0 when fully visible, 0.0 when at/beyond cutoff, smooth transition in the last FADE_ZONE_BLOCKS before cutoff. Returns -1 if beyond cutoff (caller should skip rendering entirely).
    • 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
    • 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.