Package com.hbm_m.client.render
Class RenderDistanceHelper
java.lang.Object
com.hbm_m.client.render.RenderDistanceHelper
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 TypeMethodDescriptionstatic floatcomputeAnimatedFade(net.minecraft.core.BlockPos blockPos) Computes a fade factor for animated parts at the given position.static floatcomputeAnimatedFade(net.minecraft.world.level.block.entity.BlockEntity blockEntity) Safely computes animated fade factor, bypassing fading entirely on Create contraptions.static floatcomputeFade(net.minecraft.core.BlockPos blockPos, double maxBlocks) Core fade calculation.static floatcomputeFade(net.minecraft.world.level.block.entity.BlockEntity blockEntity, double maxBlocks) Safely computes fade factor, bypassing fading entirely on Create contraptions.static floatcomputeStaticFade(net.minecraft.core.BlockPos blockPos) Computes a fade factor for static parts at the given position.static floatcomputeStaticFade(net.minecraft.world.level.block.entity.BlockEntity blockEntity) Safely computes static fade factor, bypassing fading entirely on Create contraptions.static doubledistanceSqToCamera(net.minecraft.core.BlockPos blockPos) Computes the squared distance from the camera to the block center.static doubleReturns the maximum render distance for animated/dynamic parts in blocks.static doubleSquared camera distance threshold for full 8-cornerLightSampleCachesampling.static doubleReturns the maximum render distance for static parts in blocks.static intConverts a BER view distance config (in chunks) to blocks, matchingBlockEntityRenderer.getViewDistance().static booleanshouldSkipAnimation(net.minecraft.core.BlockPos blockPos) Whether the animated parts should be completely skipped (beyond cutoff).static booleanshouldSkipAnimation(net.minecraft.world.level.block.entity.BlockEntity blockEntity) Safely checks if animation should be skipped, bypassing the check on Create contraptions.
-
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 tomaxBlocks- 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, matchingBlockEntityRenderer.getViewDistance(). -
getLightCornerDetailDistanceSq
public static double getLightCornerDetailDistanceSq()Squared camera distance threshold for full 8-cornerLightSampleCachesampling. Beyond this, callers should use uniform corner UV from vanilla packed light.
-