Skip to content

Commit

Permalink
mimic item entity rendering for distance calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ghzdude committed Mar 27, 2024
1 parent 00ddf44 commit 0ee0a01
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ public <T extends MetaTileEntity & ITieredMetaTileEntity> void renderMachine(CCR

public static void renderChestStack(double x, double y, double z, MetaTileEntityQuantumChest machine,
ItemStack stack, long count, float partialTicks) {
if (stack.isEmpty() || count == 0 || !ConfigHolder.client.enableFancyChestRender)
return;

int range = 16;
if (x > range || y > range || z > range ||
x < -range || y < -range || z < -range)
if (!ConfigHolder.client.enableFancyChestRender || stack.isEmpty() || count == 0 || !canRender(x, y, z))
return;

float lastBrightnessX = OpenGlHelper.lastBrightnessX;
Expand Down Expand Up @@ -177,10 +172,18 @@ public static void renderTankFluid(CCRenderState renderState, Matrix4 translatio
renderState.reset();
}

public static boolean canRender(double x, double y, double z) {
double distance = (x * x) + (y * y) + (z * z);
return canRender(distance);
}

public static boolean canRender(double distanceSq) {
int range = 8 * (Minecraft.getMinecraft().gameSettings.renderDistanceChunks / 8);
return distanceSq < range * range;
}

public static void renderTankAmount(double x, double y, double z, EnumFacing frontFacing, long amount) {
int range = 16;
if (x > range || y > range || z > range ||
x < -range || y < -range || z < -range)
if (!canRender(x, y, z))
return;

float lastBrightnessX = OpenGlHelper.lastBrightnessX;
Expand Down

0 comments on commit 0ee0a01

Please sign in to comment.