Skip to content

Commit

Permalink
rework rendering logic to remove the inner for loop
Browse files Browse the repository at this point in the history
+ spobless
  • Loading branch information
ghzdude committed Dec 26, 2023
1 parent a2fb60a commit f7c2f04
Showing 1 changed file with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,32 @@ public void renderMachine(CCRenderState renderState, Matrix4 translation, IVerte

TextureAtlasSprite hullTexture = Textures.VOLTAGE_CASINGS[tier]
.getSpriteOnSide(RenderSide.bySide(EnumFacing.NORTH));
for (EnumFacing facing : EnumFacing.VALUES) {
for (EnumFacing boxFace : EnumFacing.VALUES) {
// do not render the box when "facing" is "frontFacing", otherwise
// render when the box face matches facing, or
// render when the box face is opposite of facing, or
// render when the box face is the front face
if (facing != frontFacing &&
(boxFace == facing || boxFace == facing.getOpposite() || boxFace == frontFacing)) {

Textures.renderFace(renderState, translation, pipeline, boxFace, boxFacingMap.get(facing),
hullTexture,
BlockRenderLayer.CUTOUT_MIPPED);
}
}

for (var facing : boxFacingMap.keySet()) {
// do not render the box at the front face when "facing" is "frontFacing"
if (facing == frontFacing) continue;

// render when the box face matches facing
Textures.renderFace(renderState, translation, pipeline, facing, boxFacingMap.get(facing),
hullTexture, BlockRenderLayer.CUTOUT_MIPPED);

// render when the box face is opposite of facing
Textures.renderFace(renderState, translation, pipeline, facing.getOpposite(), boxFacingMap.get(facing),
hullTexture, BlockRenderLayer.CUTOUT_MIPPED);
}

// render the sides of the box that face the front face
if (frontFacing.getAxis() == EnumFacing.Axis.Y) return;
Textures.renderFace(renderState, translation, pipeline, frontFacing, boxFacingMap.get(EnumFacing.DOWN),
hullTexture, BlockRenderLayer.CUTOUT_MIPPED);
Textures.renderFace(renderState, translation, pipeline, frontFacing, boxFacingMap.get(EnumFacing.UP),
hullTexture, BlockRenderLayer.CUTOUT_MIPPED);

EnumFacing facing = frontFacing.rotateYCCW();
Textures.renderFace(renderState, translation, pipeline, frontFacing, boxFacingMap.get(facing),
hullTexture, BlockRenderLayer.CUTOUT_MIPPED);
Textures.renderFace(renderState, translation, pipeline, frontFacing, boxFacingMap.get(facing.getOpposite()),
hullTexture, BlockRenderLayer.CUTOUT_MIPPED);
}

public static void renderChestStack(double x, double y, double z, MetaTileEntityQuantumChest machine,
Expand Down

0 comments on commit f7c2f04

Please sign in to comment.