for (int dy = y; dy < sizeYOffset; ++dy) {
int id = chunkCache.getBlockId(dx, dy, dz);
if (id > 0) {
String customTexture = null;
String customTextureAddon = null;
GenericBlockDesign design = null;
CustomBlock mat = null;
if (customBlockIds != null) {
int key = ((dx & 0xF) << 12) | ((dz & 0xF) << 8) | (dy & 0xFF);
if (customBlockIds[key] != 0) {
mat = MaterialData.getCustomBlock(customBlockIds[key]);
if (mat != null) {
design = (GenericBlockDesign) mat.getBlockDesign(customBlockData == null ? 0 : customBlockData[key]);
}
}
}
if (design != null) {
customTexture = design.getTextureURL();
customTextureAddon = design.getTextureAddon();
}
if (customTexture != null){
boolean found = false;
// Search for the custom texture in our list
for(int i = 0; i < hitTextures.size(); i++){
if(hitTextures.get(i).equals(customTexture) && hitTexturesPlugins.get(i).equals(customTextureAddon)) {
found = true;
break;
}
}
// If it is not already accounted for, add it so we do an additional pass for it.
if (!found) {
hitTextures.add(customTexture);
hitTexturesPlugins.add(customTextureAddon);
}
// Do not render if we are using a different texture than the current one
if (!hitTextures.get(currentTexture).equals(customTexture) || !hitTexturesPlugins.get(currentTexture).equals(customTextureAddon)) {
continue;
}
// Do not render if we are not using the terrain.png and can't find a valid texture for this custom block
} else if (currentTexture != 0) {
continue;
}
Block block = Block.blocksList[id];
if (block != null) {
if (renderPass == 0 && block.hasTileEntity()) {
TileEntity var20 = chunkCache.getBlockTileEntity(dx, dy, dz);
if (TileEntityRenderer.instance.hasSpecialRenderer(var20)) {
this.tileEntityRenderers.add(var20);
}
}
// Determine which pass this block needs to be rendered on
int blockRenderPass = RenderPass.getBlockRenderPass(block);
if (design != null) {
blockRenderPass = design.getRenderPass();
}
if (blockRenderPass != renderPass) {
skipRenderPass = true;
} else {
if (design != null) {
oldBounds[0] = (float) block.minX;
oldBounds[1] = (float) block.minY;
oldBounds[2] = (float) block.minZ;
oldBounds[3] = (float) block.maxX;
oldBounds[4] = (float) block.maxY;
oldBounds[5] = (float) block.maxZ;
block.setBlockBounds(design.getLowXBound(), design.getLowYBound(), design.getLowZBound(), design.getHighXBound(), design.getHighYBound(), design.getHighZBound());
rendered |= design.renderBlock(mat, dx, dy, dz);
block.setBlockBounds(oldBounds[0], oldBounds[1], oldBounds[2], oldBounds[3], oldBounds[4], oldBounds[5]);
} else {
rendered |= blockRenderer.renderBlockByRenderType(block, dx, dy, dz);
}
}