|
22 | 22 | import net.minecraft.util.EnumFacing;
|
23 | 23 | import net.minecraft.util.ResourceLocation;
|
24 | 24 | import net.minecraft.util.math.BlockPos;
|
| 25 | +import net.minecraft.util.math.MathHelper; |
25 | 26 | import net.minecraft.world.IBlockAccess;
|
26 | 27 | import net.minecraft.world.World;
|
27 | 28 | import net.minecraftforge.fluids.FluidStack;
|
@@ -108,12 +109,7 @@ public <T extends MetaTileEntity & ITieredMetaTileEntity> void renderMachine(CCR
|
108 | 109 |
|
109 | 110 | public static void renderChestStack(double x, double y, double z, MetaTileEntityQuantumChest machine,
|
110 | 111 | 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)) |
117 | 113 | return;
|
118 | 114 |
|
119 | 115 | float lastBrightnessX = OpenGlHelper.lastBrightnessX;
|
@@ -177,10 +173,19 @@ public static void renderTankFluid(CCRenderState renderState, Matrix4 translatio
|
177 | 173 | renderState.reset();
|
178 | 174 | }
|
179 | 175 |
|
| 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 | + |
180 | 187 | 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)) |
184 | 189 | return;
|
185 | 190 |
|
186 | 191 | float lastBrightnessX = OpenGlHelper.lastBrightnessX;
|
|
0 commit comments