Skip to content

Commit 8709399

Browse files
committed
mimic item entity rendering for distance calculation
1 parent 00ddf44 commit 8709399

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/main/java/gregtech/client/renderer/texture/custom/QuantumStorageRenderer.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import net.minecraft.util.EnumFacing;
2323
import net.minecraft.util.ResourceLocation;
2424
import net.minecraft.util.math.BlockPos;
25+
import net.minecraft.util.math.MathHelper;
2526
import net.minecraft.world.IBlockAccess;
2627
import net.minecraft.world.World;
2728
import net.minecraftforge.fluids.FluidStack;
@@ -108,12 +109,7 @@ public <T extends MetaTileEntity & ITieredMetaTileEntity> void renderMachine(CCR
108109

109110
public static void renderChestStack(double x, double y, double z, MetaTileEntityQuantumChest machine,
110111
ItemStack stack, long count, float partialTicks) {
111-
if (stack.isEmpty() || count == 0 || !ConfigHolder.client.enableFancyChestRender)
112-
return;
113-
114-
int range = 16;
115-
if (x > range || y > range || z > range ||
116-
x < -range || y < -range || z < -range)
112+
if (!ConfigHolder.client.enableFancyChestRender || stack.isEmpty() || count == 0 || !canRender(x, y, z))
117113
return;
118114

119115
float lastBrightnessX = OpenGlHelper.lastBrightnessX;
@@ -177,10 +173,19 @@ public static void renderTankFluid(CCRenderState renderState, Matrix4 translatio
177173
renderState.reset();
178174
}
179175

176+
public static boolean canRender(double x, double y, double z) {
177+
double distance = (x * x) + (y * y) + (z * z);
178+
return canRender(distance);
179+
}
180+
181+
public static boolean canRender(double distanceSq) {
182+
double range = 8 *
183+
MathHelper.clamp((double) Minecraft.getMinecraft().gameSettings.renderDistanceChunks / 8, 1.0, 2.5);
184+
return distanceSq < range * range;
185+
}
186+
180187
public static void renderTankAmount(double x, double y, double z, EnumFacing frontFacing, long amount) {
181-
int range = 16;
182-
if (x > range || y > range || z > range ||
183-
x < -range || y < -range || z < -range)
188+
if (!canRender(x, y, z))
184189
return;
185190

186191
float lastBrightnessX = OpenGlHelper.lastBrightnessX;

0 commit comments

Comments
 (0)