public boolean renderCrossedSquares(Block block, int x, int y, int z, RenderBlocks renderer) { Tessellator var5 = Tessellator.instance; var5.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z)); float var6 = 1.0F; int var7 = block.colorMultiplier(renderer.blockAccess, x, y, z); float var8 = (var7 >> 16 & 255) / 255.0F; float var9 = (var7 >> 8 & 255) / 255.0F; float var10 = (var7 & 255) / 255.0F; if (EntityRenderer.anaglyphEnable) { float var11 = (var8 * 30.0F + var9 * 59.0F + var10 * 11.0F) / 100.0F; float var12 = (var8 * 30.0F + var9 * 70.0F) / 100.0F; float var13 = (var8 * 30.0F + var10 * 70.0F) / 100.0F; var8 = var11; var9 = var12; var10 = var13; } var5.setColorOpaque_F(var6 * var8, var6 * var9, var6 * var10); double new_x = x; double new_y = y; double new_z = z; if (block == Block.tallGrass) { long var17 = (x * 3129871) ^ z * 116129781L ^ y; var17 = var17 * var17 * 42317861L + var17 * 11L; new_x += (((var17 >> 16 & 15L) / 15.0F) - 0.5D) * 0.5D; new_y += (((var17 >> 20 & 15L) / 15.0F) - 1.0D) * 0.2D; new_z += (((var17 >> 24 & 15L) / 15.0F) - 0.5D) * 0.5D; } drawThreeLeaves( block, renderer.blockAccess.getBlockMetadata(x, y, z), new_x, new_y, new_z, 1.0F, renderer); return true; }
@Override public boolean renderWorldBlock( IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { BlockTikiTorch tikiTorch = (BlockTikiTorch) block; int metadata = world.getBlockMetadata(x, y, z); Tessellator tess = Tessellator.instance; tess.setColorOpaque_F(1, 1, 1); tess.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); double delta; double off; double offX = 0; double offY = 0.1875; double offZ = 0; double dX = 0; double dZ = 0; if (!tikiTorch.isUpper(metadata)) { delta = 0.25; off = 0.5 - delta; } else { delta = 0.25; off = 0; } switch (tikiTorch.getDirection(metadata)) { case 1: offX = -off; dX = -delta; break; case 2: offX = off; dX = delta; break; case 3: offZ = -off; dZ = -delta; break; case 4: offZ = off; dZ = delta; break; default: offY = 0; break; } renderer.renderTorchAtAngle(block, x + offX, y + offY, z + offZ, dX, dZ, metadata); return true; }
/** Renders any block requiring crossed squares such as reeds, flowers, and mushrooms */ public static boolean renderPlantCrossedSquares( RenderBlocks renderBlocks, Block block, int metadata, int x, int y, int z, float scale, boolean flipped) { Tessellator tessellator = Tessellator.instance; tessellator.setBrightness(block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y, z)); Icon icon = FlowerPotHandler.getPlantIcon(new ItemStack(block, 1, metadata)); setPlantColor(block, x, y, z); double uMin = icon.getMinU(); double vMin = icon.getMinV(); double uMax = icon.getMaxU(); double vMax = icon.getMaxV(); double rotation = 0.45D * scale; double xMin = x + 0.5D - rotation; double xMax = x + 0.5D + rotation; double zMin = z + 0.5D - rotation; double zMax = z + 0.5D + rotation; if (flipped) { double temp = vMin; vMin = vMax; vMax = temp; } tessellator.addVertexWithUV(xMin, y + (double) scale, zMin, uMin, vMin); tessellator.addVertexWithUV(xMin, y + 0.0D, zMin, uMin, vMax); tessellator.addVertexWithUV(xMax, y + 0.0D, zMax, uMax, vMax); tessellator.addVertexWithUV(xMax, y + (double) scale, zMax, uMax, vMin); tessellator.addVertexWithUV(xMax, y + (double) scale, zMax, uMin, vMin); tessellator.addVertexWithUV(xMax, y + 0.0D, zMax, uMin, vMax); tessellator.addVertexWithUV(xMin, y + 0.0D, zMin, uMax, vMax); tessellator.addVertexWithUV(xMin, y + (double) scale, zMin, uMax, vMin); tessellator.addVertexWithUV(xMin, y + (double) scale, zMax, uMin, vMin); tessellator.addVertexWithUV(xMin, y + 0.0D, zMax, uMin, vMax); tessellator.addVertexWithUV(xMax, y + 0.0D, zMin, uMax, vMax); tessellator.addVertexWithUV(xMax, y + (double) scale, zMin, uMax, vMin); tessellator.addVertexWithUV(xMax, y + (double) scale, zMin, uMin, vMin); tessellator.addVertexWithUV(xMax, y + 0.0D, zMin, uMin, vMax); tessellator.addVertexWithUV(xMin, y + 0.0D, zMax, uMax, vMax); tessellator.addVertexWithUV(xMin, y + (double) scale, zMax, uMax, vMin); return true; }
@Override public boolean renderWorldBlock( IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { IIcon icon = RenderBlocks.getInstance().getBlockIconFromSideAndMetadata(block, 0, 0); float minU = icon.getMinU(); float minV = icon.getMinV(); float maxU = icon.getMaxU(); float maxV = icon.getMaxV(); Tessellator t = Tessellator.instance; int lightValue = block.getMixedBrightnessForBlock(world, x, y, z); t.setColorOpaque_F(1.0F, 1.0F, 1.0F); // Bottom t.addVertexWithUV(x + 0, y + 0, z + 0, minU, minV); t.addVertexWithUV(x + 1, y + 0, z + 0, maxU, minV); t.addVertexWithUV(x + 1, y + 0, z + 1, maxU, maxV); t.addVertexWithUV(x + 0, y + 0, z + 1, minU, maxV); // Top t.addVertexWithUV(x + 0, y + 1, z + 1, minU, maxV); t.addVertexWithUV(x + 1, y + 1, z + 1, maxU, maxV); t.addVertexWithUV(x + 1, y + 1, z + 0, maxU, minV); t.addVertexWithUV(x + 0, y + 1, z + 0, minU, minV); // Side t.addVertexWithUV(x + 0, y + 0, z + 1, minU, maxV); t.addVertexWithUV(x + 0, y + 1, z + 1, maxU, maxV); t.addVertexWithUV(x + 0, y + 1, z + 0, maxU, minV); t.addVertexWithUV(x + 0, y + 0, z + 0, minU, minV); // Side t.addVertexWithUV(x + 1, y + 0, z + 0, minU, minV); t.addVertexWithUV(x + 1, y + 1, z + 0, maxU, minV); t.addVertexWithUV(x + 1, y + 1, z + 1, maxU, maxV); t.addVertexWithUV(x + 1, y + 0, z + 1, minU, maxV); // Side t.addVertexWithUV(x + 1, y + 0, z + 1, minU, maxV); t.addVertexWithUV(x + 1, y + 1, z + 1, maxU, maxV); t.addVertexWithUV(x + 0, y + 1, z + 1, maxU, minV); t.addVertexWithUV(x + 0, y + 0, z + 1, minU, minV); // Side t.addVertexWithUV(x + 0, y + 0, z + 0, minU, minV); t.addVertexWithUV(x + 0, y + 1, z + 0, maxU, minV); t.addVertexWithUV(x + 1, y + 1, z + 0, maxU, maxV); t.addVertexWithUV(x + 1, y + 0, z + 0, minU, maxV); return false; }
public boolean renderBlockCrops( Block p_147796_1_, int p_147796_2_, int p_147796_3_, int p_147796_4_, IBlockAccess blockAccess, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; tessellator.setBrightness( p_147796_1_.getMixedBrightnessForBlock(blockAccess, p_147796_2_, p_147796_3_, p_147796_4_)); tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); renderer.renderBlockCropsImpl( p_147796_1_, blockAccess.getBlockMetadata(p_147796_2_, p_147796_3_, p_147796_4_), (double) p_147796_2_, (double) ((float) p_147796_3_ - 0.0625F), (double) p_147796_4_); return true; }
private boolean renderBlockCrossedSquares( IBlockAccess blockAccess, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; tessellator.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z)); float f = 1.0F; int l = block.colorMultiplier(blockAccess, x, y, z); float f1 = (float) (l >> 16 & 255) / 255.0F; float f2 = (float) (l >> 8 & 255) / 255.0F; float f3 = (float) (l & 255) / 255.0F; if (EntityRenderer.anaglyphEnable) { float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F; float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F; f1 = f4; f2 = f5; f3 = f6; } tessellator.setColorOpaque_F(f * f1, f * f2, f * f3); double xx = (double) x; double yy = (double) y; double zz = (double) z; if (block == Blocks.tallgrass) { long i1 = (long) (x * 3129871) ^ (long) z * 116129781L ^ (long) y; i1 = i1 * i1 * 42317861L + i1 * 11L; xx += ((double) ((float) (i1 >> 16 & 15L) / 15.0F) - 0.5D) * 0.5D; yy += ((double) ((float) (i1 >> 20 & 15L) / 15.0F) - 1.0D) * 0.2D; zz += ((double) ((float) (i1 >> 24 & 15L) / 15.0F) - 0.5D) * 0.5D; } drawCrossedSquares( blockAccess, xx, yy, zz, 1.0F, block, blockAccess.getBlockMetadata(x, y, z), renderer); return true; }
@Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { CCRenderState.reset(); CCRenderState.useNormals(true); CCRenderState.useModelColours(true); TileEntityRedNetCable _cable = (TileEntityRedNetCable)world.getBlockTileEntity(x, y, z); TileEntityRedNetEnergy _cond = null; int brightness = block.getMixedBrightnessForBlock(world, x, y, z); int bandBrightness = brightBand ? 0xd00070 : brightness; Tessellator tess = Tessellator.instance; tess.setColorOpaque_F(1,1,1); tess.setBrightness(brightness); Translation tlate = new Translation(new Vector3(x, y, z)); base.render(tlate, uvt); if (_cable instanceof TileEntityRedNetEnergy) { cage.render(tlate, uvt); _cond = (TileEntityRedNetEnergy)_cable; } for (ForgeDirection f : ForgeDirection.VALID_DIRECTIONS) { int side = f.ordinal(); RedNetConnectionType state = _cable.getConnectionState(f); switch (state.flags & 31) { case 11: // isCable, isSingleSubnet tess.setBrightness(bandBrightness); band[side].setColour(_cable.getSideColorValue(f)); band[side].render(tlate, uvt); tess.setColorOpaque_F(1,1,1); tess.setBrightness(brightness); case 19: // isCable, isAllSubnets if (state.isSingleSubnet) { iface[side].render(tlate, uvt); grip[side].render(tlate, uvt); } else cable[side].render(tlate, uvt); break; case 13: // isPlate, isSingleSubnet tess.setBrightness(bandBrightness); band[side].setColour(_cable.getSideColorValue(f)); band[side].render(tlate, uvt); platef[side].setColour(_cable.getSideColorValue(f)); platef[side].render(tlate, uvt); tess.setColorOpaque_F(1,1,1); tess.setBrightness(brightness); case 21: // isPlate, isAllSubnets iface[side].render(tlate, uvt); plate[side].render(tlate, uvt); if (state.isAllSubnets) { platef[side].setColour(-1); platef[side].render(tlate, uvt); } default: break; } if (_cond != null && _cond.isInterfacing(f)) { wire[side].render(tlate, uvt); if (_cond.interfaceMode(f) != 4) caps[side].render(tlate, uvt); } } return true; }
@Override public boolean renderWorldBlock( IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks rb) { Tessellator v5 = Tessellator.instance; int meta = world.getBlockMetadata(x, y, z); int color = b.colorMultiplier(world, x, y, z); float red = ReikaColorAPI.getRed(color) / 255F; float grn = ReikaColorAPI.getGreen(color) / 255F; float blu = ReikaColorAPI.getBlue(color) / 255F; rb.renderStandardBlockWithAmbientOcclusion(b, x, y, z, red, grn, blu); TileEntityColorLock te = (TileEntityColorLock) world.getTileEntity(x, y, z); if (!te.isHeldOpen()) { Collection<CrystalElement> c = te.getClosedColors(); if (!c.isEmpty()) { v5.addTranslation(x, y, z); IIcon[] ico = new IIcon[] {ChromaIcons.BASICFADE.getIcon(), ChromaIcons.FRAME.getIcon()}; int s = c.size(); double iy = 0.0625; double dx = 0.0625; // s will never be more than 4 double spc = 0.03125; double w = (1D - (dx * 2D) - spc * (s - 1)) / s; double sp = spc + w; double o = 0.005; for (CrystalElement e : c) { // if (!BlockColoredLock.isOpen(e, te.getChannel())) { does not work on servers for (int i = 0; i < ico.length; i++) { if (i == 0) { int clr = ReikaColorAPI.getColorWithBrightnessMultiplier( ReikaColorAPI.getModifiedSat(e.getColor(), 0.85F), 0.85F); v5.setColorRGBA_I(clr, 192); v5.setBrightness(240); } else { v5.setColorOpaque_I(0xffffff); v5.setBrightness(b.getMixedBrightnessForBlock(world, x, y, z)); } for (int k = 0; k < 4; k++) { float u = ico[i].getMinU(); float v = ico[i].getMinV(); float du = ico[i].getMaxU(); float dv = ico[i].getMaxV(); if (k == 0 || k == 3) { float scr = v; v = dv; dv = scr; } switch (k) { case 0: v5.addVertexWithUV(1 + o, dx, iy, du, v); v5.addVertexWithUV(1 + o, dx + w, iy, u, v); v5.addVertexWithUV(1 + o, dx + w, 1 - iy, u, dv); v5.addVertexWithUV(1 + o, dx, 1 - iy, du, dv); break; case 1: v5.addVertexWithUV(1 - iy, dx, 1 + o, du, dv); v5.addVertexWithUV(1 - iy, dx + w, 1 + o, u, dv); v5.addVertexWithUV(iy, dx + w, 1 + o, u, v); v5.addVertexWithUV(iy, dx, 1 + o, du, v); break; case 2: v5.addVertexWithUV(-o, dx, 1 - iy, du, dv); v5.addVertexWithUV(-o, dx + w, 1 - iy, u, dv); v5.addVertexWithUV(-o, dx + w, iy, u, v); v5.addVertexWithUV(-o, dx, iy, du, v); break; case 3: v5.addVertexWithUV(iy, dx, -o, du, v); v5.addVertexWithUV(iy, dx + w, -o, u, v); v5.addVertexWithUV(1 - iy, dx + w, -o, u, dv); v5.addVertexWithUV(1 - iy, dx, -o, du, dv); break; } } } dx += sp; // } } v5.addTranslation(-x, -y, -z); } } return true; }
@Override public boolean renderWorldBlock( IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { if (modelId == RENDER_ID) { final BlockBrewKettle brewKettle = (BlockBrewKettle) block; final double d = 0.0625D; float f = 1.0F; renderer.renderStandardBlock(block, x, y, z); final Tessellator tes = Tessellator.instance; tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); int color = block.colorMultiplier(world, x, y, z); float r = (float) (color >> 16 & 255) / 255.0F; float g = (float) (color >> 8 & 255) / 255.0F; float b = (float) (color & 255) / 255.0F; float f4; if (EntityRenderer.anaglyphEnable) { final float f5 = (r * 30.0F + g * 59.0F + b * 11.0F) / 100.0F; f4 = (r * 30.0F + g * 70.0F) / 100.0F; final float f6 = (r * 30.0F + b * 70.0F) / 100.0F; r = f5; g = f4; b = f6; } tes.setColorOpaque_F(f * r, f * g, f * b); f4 = 0.125F; renderer.renderFaceXPos( block, (double) (x - 1.0F + f4), (double) y, (double) z, brewKettle.getIconByIndex(2)); renderer.renderFaceXNeg( block, (double) (x + 1.0F - f4), (double) y, (double) z, brewKettle.getIconByIndex(2)); renderer.renderFaceZPos( block, (double) x, (double) y, (double) (z - 1.0F + f4), brewKettle.getIconByIndex(2)); renderer.renderFaceZNeg( block, (double) x, (double) y, (double) (z + 1.0F - f4), brewKettle.getIconByIndex(2)); renderer.renderFaceYPos( block, (double) x, (double) (y - 1.0F + 0.25F), (double) z, brewKettle.getIconByIndex(1)); renderer.renderFaceYNeg( block, (double) x, (double) (y + 1.0F - 0.75F), (double) z, brewKettle.getIconByIndex(1)); // Render Liquid final TileEntityBrewKettle te = (TileEntityBrewKettle) world.getTileEntity(x, y, z); if (te != null) { for (int i = 0; i < 2; ++i) { if (te.isFluidTankFilled(i)) { final Fluid fluid = te.getFluid(i); color = fluid.getColor(); r = (float) (color >> 16 & 255) / 255.0F; g = (float) (color >> 8 & 255) / 255.0F; b = (float) (color & 255) / 255.0F; f = 1.0F; tes.setColorOpaque_F(f * r, f * g, f * b); f = te.getFluidAmount(i) * FLUID_HEIGHT / te.getFluidTank(i).getCapacity(); renderer.setRenderBounds(2 * d, 0.0D, 2 * d, 14 * d, (double) (0.25F + f), 14 * d); renderer.renderFaceYPos(block, (double) x, (double) y, (double) z, fluid.getIcon()); } } } renderer.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); } return true; }
@Override public boolean renderWorldBlock( IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { if (!(block instanceof BlockFluidBase)) { return false; } Tessellator tessellator = Tessellator.instance; int color = block.colorMultiplier(world, x, y, z); float red = (color >> 16 & 255) / 255.0F; float green = (color >> 8 & 255) / 255.0F; float blue = (color & 255) / 255.0F; BlockFluidBase theFluid = (BlockFluidBase) block; int bMeta = world.getBlockMetadata(x, y, z); boolean renderTop = world.getBlock(x, y - theFluid.densityDir, z) != theFluid; boolean renderBottom = block.shouldSideBeRendered(world, x, y + theFluid.densityDir, z, 0) && world.getBlock(x, y + theFluid.densityDir, z) != theFluid; boolean[] renderSides = new boolean[] { block.shouldSideBeRendered(world, x, y, z - 1, 2), block.shouldSideBeRendered(world, x, y, z + 1, 3), block.shouldSideBeRendered(world, x - 1, y, z, 4), block.shouldSideBeRendered(world, x + 1, y, z, 5) }; if (!renderTop && !renderBottom && !renderSides[0] && !renderSides[1] && !renderSides[2] && !renderSides[3]) { return false; } else { boolean rendered = false; double heightNW, heightSW, heightSE, heightNE; float flow11 = getFluidHeightForRender(world, x, y, z, theFluid); if (flow11 != 1) { float flow00 = getFluidHeightForRender(world, x - 1, y, z - 1, theFluid); float flow01 = getFluidHeightForRender(world, x - 1, y, z, theFluid); float flow02 = getFluidHeightForRender(world, x - 1, y, z + 1, theFluid); float flow10 = getFluidHeightForRender(world, x, y, z - 1, theFluid); float flow12 = getFluidHeightForRender(world, x, y, z + 1, theFluid); float flow20 = getFluidHeightForRender(world, x + 1, y, z - 1, theFluid); float flow21 = getFluidHeightForRender(world, x + 1, y, z, theFluid); float flow22 = getFluidHeightForRender(world, x + 1, y, z + 1, theFluid); heightNW = getFluidHeightAverage(new float[] {flow00, flow01, flow10, flow11}); heightSW = getFluidHeightAverage(new float[] {flow01, flow02, flow12, flow11}); heightSE = getFluidHeightAverage(new float[] {flow12, flow21, flow22, flow11}); heightNE = getFluidHeightAverage(new float[] {flow10, flow20, flow21, flow11}); } else { heightNW = flow11; heightSW = flow11; heightSE = flow11; heightNE = flow11; } boolean rises = theFluid.densityDir == 1; if (renderer.renderAllFaces || renderTop) { rendered = true; IIcon iconStill = getIcon(block.getIcon(1, bMeta)); float flowDir = (float) BlockFluidBase.getFlowDirection(world, x, y, z); if (flowDir > -999.0F) { iconStill = getIcon(block.getIcon(2, bMeta)); } heightNW -= RENDER_OFFSET; heightSW -= RENDER_OFFSET; heightSE -= RENDER_OFFSET; heightNE -= RENDER_OFFSET; double u1, u2, u3, u4, v1, v2, v3, v4; if (flowDir < -999.0F) { u2 = iconStill.getInterpolatedU(0.0D); v2 = iconStill.getInterpolatedV(0.0D); u1 = u2; v1 = iconStill.getInterpolatedV(16.0D); u4 = iconStill.getInterpolatedU(16.0D); v4 = v1; u3 = u4; v3 = v2; } else { float xFlow = MathHelper.sin(flowDir) * 0.25F; float zFlow = MathHelper.cos(flowDir) * 0.25F; u2 = iconStill.getInterpolatedU(8.0F + (-zFlow - xFlow) * 16.0F); v2 = iconStill.getInterpolatedV(8.0F + (-zFlow + xFlow) * 16.0F); u1 = iconStill.getInterpolatedU(8.0F + (-zFlow + xFlow) * 16.0F); v1 = iconStill.getInterpolatedV(8.0F + (zFlow + xFlow) * 16.0F); u4 = iconStill.getInterpolatedU(8.0F + (zFlow + xFlow) * 16.0F); v4 = iconStill.getInterpolatedV(8.0F + (zFlow - xFlow) * 16.0F); u3 = iconStill.getInterpolatedU(8.0F + (zFlow - xFlow) * 16.0F); v3 = iconStill.getInterpolatedV(8.0F + (-zFlow - xFlow) * 16.0F); } tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); tessellator.setColorOpaque_F(LIGHT_Y_POS * red, LIGHT_Y_POS * green, LIGHT_Y_POS * blue); if (!rises) { tessellator.addVertexWithUV(x + 0, y + heightNW, z + 0, u2, v2); tessellator.addVertexWithUV(x + 0, y + heightSW, z + 1, u1, v1); tessellator.addVertexWithUV(x + 1, y + heightSE, z + 1, u4, v4); tessellator.addVertexWithUV(x + 1, y + heightNE, z + 0, u3, v3); } else { tessellator.addVertexWithUV(x + 1, y + 1 - heightNE, z + 0, u3, v3); tessellator.addVertexWithUV(x + 1, y + 1 - heightSE, z + 1, u4, v4); tessellator.addVertexWithUV(x + 0, y + 1 - heightSW, z + 1, u1, v1); tessellator.addVertexWithUV(x + 0, y + 1 - heightNW, z + 0, u2, v2); } } if (renderer.renderAllFaces || renderBottom) { rendered = true; tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y - 1, z)); if (!rises) { tessellator.setColorOpaque_F(LIGHT_Y_NEG * red, LIGHT_Y_NEG * green, LIGHT_Y_NEG * blue); renderer.renderFaceYNeg(block, x, y + RENDER_OFFSET, z, getIcon(block.getIcon(0, bMeta))); } else { tessellator.setColorOpaque_F(LIGHT_Y_POS * red, LIGHT_Y_POS * green, LIGHT_Y_POS * blue); renderer.renderFaceYPos(block, x, y + RENDER_OFFSET, z, getIcon(block.getIcon(1, bMeta))); } } for (int side = 0; side < 4; ++side) { int x2 = x; int z2 = z; switch (side) { case 0: --z2; break; case 1: ++z2; break; case 2: --x2; break; case 3: ++x2; break; } IIcon iconFlow = getIcon(block.getIcon(side + 2, bMeta)); if (renderer.renderAllFaces || renderSides[side]) { rendered = true; double ty1; double tx1; double ty2; double tx2; double tz1; double tz2; if (side == 0) { ty1 = heightNW; ty2 = heightNE; tx1 = x; tx2 = x + 1; tz1 = z + RENDER_OFFSET; tz2 = z + RENDER_OFFSET; } else if (side == 1) { ty1 = heightSE; ty2 = heightSW; tx1 = x + 1; tx2 = x; tz1 = z + 1 - RENDER_OFFSET; tz2 = z + 1 - RENDER_OFFSET; } else if (side == 2) { ty1 = heightSW; ty2 = heightNW; tx1 = x + RENDER_OFFSET; tx2 = x + RENDER_OFFSET; tz1 = z + 1; tz2 = z; } else { ty1 = heightNE; ty2 = heightSE; tx1 = x + 1 - RENDER_OFFSET; tx2 = x + 1 - RENDER_OFFSET; tz1 = z; tz2 = z + 1; } float u1Flow = iconFlow.getInterpolatedU(0.0D); float u2Flow = iconFlow.getInterpolatedU(8.0D); float v1Flow = iconFlow.getInterpolatedV((1.0D - ty1) * 16.0D * 0.5D); float v2Flow = iconFlow.getInterpolatedV((1.0D - ty2) * 16.0D * 0.5D); float v3Flow = iconFlow.getInterpolatedV(8.0D); tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x2, y, z2)); float sideLighting = 1.0F; if (side < 2) { sideLighting = LIGHT_XZ_NEG; } else { sideLighting = LIGHT_XZ_POS; } tessellator.setColorOpaque_F( LIGHT_Y_POS * sideLighting * red, LIGHT_Y_POS * sideLighting * green, LIGHT_Y_POS * sideLighting * blue); if (!rises) { tessellator.addVertexWithUV(tx1, y + ty1, tz1, u1Flow, v1Flow); tessellator.addVertexWithUV(tx2, y + ty2, tz2, u2Flow, v2Flow); tessellator.addVertexWithUV(tx2, y + 0, tz2, u2Flow, v3Flow); tessellator.addVertexWithUV(tx1, y + 0, tz1, u1Flow, v3Flow); } else { tessellator.addVertexWithUV(tx1, y + 1 - 0, tz1, u1Flow, v3Flow); tessellator.addVertexWithUV(tx2, y + 1 - 0, tz2, u2Flow, v3Flow); tessellator.addVertexWithUV(tx2, y + 1 - ty2, tz2, u2Flow, v2Flow); tessellator.addVertexWithUV(tx1, y + 1 - ty1, tz1, u1Flow, v1Flow); } } } renderer.renderMinY = 0; renderer.renderMaxY = 1; return rendered; } }
private void renderGeode( IBlockAccess world, int x, int y, int z, Block b, int meta, RenderBlocks rb) { /* Coordinate c = new Coordinate(x, y, z); Long val = renderMap.get(c); if (val != null) ReikaJavaLibrary.pConsole("Rerendering "+TieredOres.list[meta]+" geode at "+x+", "+y+", "+z+"; "+(System.currentTimeMillis()-val.longValue())+" ms since last render here."); else ReikaJavaLibrary.pConsole("Rerendering "+TieredOres.list[meta]+" geode at "+x+", "+y+", "+z+"; Has not rendered before."); renderMap.put(c, System.currentTimeMillis()); */ TessellatorVertexList v5 = new TessellatorVertexList(); Tessellator.instance.setColorOpaque_I(0xffffff); Tessellator.instance.addTranslation(x, y, z); IIcon stone = ((BlockTieredOre) b).getDisguise(meta).getIcon(0, 0); float us = stone.getMinU(); float vs = stone.getMinV(); float dus = stone.getMaxU(); float dvs = stone.getMaxV(); IIcon obsidian = Blocks.obsidian.getIcon(0, 0); float ub = obsidian.getMinU(); float vb = obsidian.getMinV(); float dub = obsidian.getMaxU(); float dvb = obsidian.getMaxV(); IIcon ico = ((BlockTieredOre) b).getGeodeIcon(meta); float uo = ico.getMinU(); float vo = ico.getMinV(); float duo = ico.getMaxU(); float dvo = ico.getMaxV(); double s = 1D / numSections; int da = offsetArray[(x % 16 + 16) % 16][(y % 16 + 16) % 16][(z % 16 + 16) % 16]; for (int i = 0; i < numSections; i++) { double d = i * s; for (int k = 0; k < numSections; k++) { double d2 = k * s; boolean center = false; // ReikaMathLibrary.isValueInsideBoundsIncl(2, numSections-3, i) && // ReikaMathLibrary.isValueInsideBoundsIncl(2, numSections-3, k); // center |= ReikaMathLibrary.isValueInsideBoundsIncl(1, numSections-2, i) && // ReikaMathLibrary.isValueInsideBoundsIncl(2, numSections-3, k); // center |= ReikaMathLibrary.isValueInsideBoundsIncl(2, numSections-3, i) && // ReikaMathLibrary.isValueInsideBoundsIncl(1, numSections-2, k); float us1 = center ? (float) (ub + (dub - ub) * d) : (float) (us + (dus - us) * d); float vs1 = center ? (float) (vb + (dvb - vb) * d2) : (float) (vs + (dvs - vs) * d2); float us2 = center ? (float) (ub + (dub - ub) * (d + s)) : (float) (us + (dus - us) * (d + s)); float vs2 = center ? (float) (vb + (dvb - vb) * (d2 + s)) : (float) (vs + (dvs - vs) * (d2 + s)); v5.addVertexWithUV(d, stoneOffsets[da][(i) * numSections + (k + 1)], d2 + s, us1, vs1); v5.addVertexWithUV( d + s, stoneOffsets[da][(i + 1) * numSections + (k + 1)], d2 + s, us2, vs1); v5.addVertexWithUV(d + s, stoneOffsets[da][(i + 1) * numSections + (k)], d2, us2, vs2); v5.addVertexWithUV(d, stoneOffsets[da][(i) * numSections + (k)], d2, us1, vs2); } } /* if (world != null) { ReikaJavaLibrary.pConsole("*************************************"); for (int i = 0; i < 6; i++) { ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i]; ReikaJavaLibrary.pConsole(dir+" > "+b.shouldSideBeRendered(world, x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, dir.ordinal())); } ReikaJavaLibrary.pConsole("---------------------------------------"); } */ if (world == null || b.shouldSideBeRendered(world, x, y + 1, z, ForgeDirection.UP.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x, y + 1, z)); Tessellator.instance.setColorOpaque_F(1F, 1F, 1F); } Tessellator.instance.setNormal(0, 1, 0); v5.render(); } v5.invertY(); if (world == null || b.shouldSideBeRendered(world, x, y - 1, z, ForgeDirection.DOWN.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x, y - 1, z)); Tessellator.instance.setColorOpaque_F(0.5F, 0.5F, 0.5F); } Tessellator.instance.setNormal(0, -1, 0); v5.render(); } v5.rotateYtoX(); if (world == null || b.shouldSideBeRendered(world, x - 1, y, z, ForgeDirection.WEST.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x - 1, y, z)); Tessellator.instance.setColorOpaque_F(0.8F, 0.8F, 0.8F); } Tessellator.instance.setNormal(-1, 0, 0); v5.render(); } v5.invertX(); if (world == null || b.shouldSideBeRendered(world, x + 1, y, z, ForgeDirection.EAST.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x + 1, y, z)); Tessellator.instance.setColorOpaque_F(0.8F, 0.8F, 0.8F); } Tessellator.instance.setNormal(1, 0, 0); v5.render(); } v5.rotateXtoZ(); if (world == null || b.shouldSideBeRendered(world, x, y, z + 1, ForgeDirection.SOUTH.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x, y, z + 1)); Tessellator.instance.setColorOpaque_F(0.7F, 0.7F, 0.7F); } Tessellator.instance.setNormal(0, 0, -1); v5.render(); } v5.invertZ(); if (world == null || b.shouldSideBeRendered(world, x, y, z - 1, ForgeDirection.NORTH.ordinal())) { if (world != null) { Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x, y, z - 1)); Tessellator.instance.setColorOpaque_F(0.7F, 0.7F, 0.7F); } Tessellator.instance.setNormal(0, 0, 1); v5.render(); } v5.clear(); if (world != null) Tessellator.instance.setBrightness(240); for (int i = 0; i < numSections; i++) { double d = i * s; double db = d + s; for (int k = 0; k < numSections; k++) { double d2 = k * s; double d2b = d2 + s; float uo1 = (float) (uo + (duo - uo) * d); float vo1 = (float) (vo + (dvo - vo) * d2); float uo2 = (float) (uo + (duo - uo) * (d + s)); float vo2 = (float) (vo + (dvo - vo) * (d2 + s)); if (i == 0) { d = 0.2; } else if (i == numSections - 1) { db = 0.8; } if (k == 0) { d2 = 0.2; } else if (k == numSections - 1) { d2b = 0.8; } v5.addVertexWithUV(d, oreOffsets[da][(i) * numSections + (k + 1)], d2b, uo1, vo1); v5.addVertexWithUV(db, oreOffsets[da][(i + 1) * numSections + (k + 1)], d2b, uo2, vo1); v5.addVertexWithUV(db, oreOffsets[da][(i + 1) * numSections + (k)], d2, uo2, vo2); v5.addVertexWithUV(d, oreOffsets[da][(i) * numSections + (k)], d2, uo1, vo2); } } if (world == null || b.shouldSideBeRendered(world, x, y + 1, z, ForgeDirection.UP.ordinal())) { Tessellator.instance.setNormal(0, 1, 0); v5.render(); } v5.invertY(); if (world == null || b.shouldSideBeRendered(world, x, y - 1, z, ForgeDirection.DOWN.ordinal())) { Tessellator.instance.setNormal(0, -1, 0); v5.render(); } v5.rotateYtoX(); if (world == null || b.shouldSideBeRendered(world, x - 1, y, z, ForgeDirection.WEST.ordinal())) { Tessellator.instance.setNormal(-1, 0, 0); v5.render(); } v5.invertX(); if (world == null || b.shouldSideBeRendered(world, x + 1, y, z, ForgeDirection.EAST.ordinal())) { Tessellator.instance.setNormal(1, 0, 0); v5.render(); } v5.rotateXtoZ(); if (world == null || b.shouldSideBeRendered(world, x, y, z + 1, ForgeDirection.SOUTH.ordinal())) { Tessellator.instance.setNormal(0, 0, -1); v5.render(); } v5.invertZ(); if (world == null || b.shouldSideBeRendered(world, x, y, z - 1, ForgeDirection.NORTH.ordinal())) { Tessellator.instance.setNormal(0, 0, 1); v5.render(); } Tessellator.instance.addTranslation(-x, -y, -z); }
@Override public boolean renderWorldBlock( IBlockAccess world, int par2, int par3, int par4, Block par1Block, int modelId, RenderBlocks renderer) { if (modelId == model) { int l = renderer.blockAccess.getBlockMetadata(par2, par3, par4); int i1 = l & 7; boolean flag = (l & 8) > 0; Tessellator tessellator = Tessellator.instance; boolean flag1 = renderer.hasOverrideBlockTexture(); if (!flag1) { renderer.setOverrideBlockTexture(renderer.getBlockIcon(Block.netherrack)); } float f = 0.25F; float f1 = 0.1875F; float f2 = 0.1875F; if (i1 == 5) { renderer.setRenderBounds( (double) (0.5F - f1), 0.0D, (double) (0.5F - f), (double) (0.5F + f1), (double) f2, (double) (0.5F + f)); } else if (i1 == 6) { renderer.setRenderBounds( (double) (0.5F - f), 0.0D, (double) (0.5F - f1), (double) (0.5F + f), (double) f2, (double) (0.5F + f1)); } else if (i1 == 4) { renderer.setRenderBounds( (double) (0.5F - f1), (double) (0.5F - f), (double) (1.0F - f2), (double) (0.5F + f1), (double) (0.5F + f), 1.0D); } else if (i1 == 3) { renderer.setRenderBounds( (double) (0.5F - f1), (double) (0.5F - f), 0.0D, (double) (0.5F + f1), (double) (0.5F + f), (double) f2); } else if (i1 == 2) { renderer.setRenderBounds( (double) (1.0F - f2), (double) (0.5F - f), (double) (0.5F - f1), 1.0D, (double) (0.5F + f), (double) (0.5F + f1)); } else if (i1 == 1) { renderer.setRenderBounds( 0.0D, (double) (0.5F - f), (double) (0.5F - f1), (double) f2, (double) (0.5F + f), (double) (0.5F + f1)); } else if (i1 == 0) { renderer.setRenderBounds( (double) (0.5F - f), (double) (1.0F - f2), (double) (0.5F - f1), (double) (0.5F + f), 1.0D, (double) (0.5F + f1)); } else if (i1 == 7) { renderer.setRenderBounds( (double) (0.5F - f1), (double) (1.0F - f2), (double) (0.5F - f), (double) (0.5F + f1), 1.0D, (double) (0.5F + f)); } renderer.renderStandardBlock(par1Block, par2, par3, par4); if (!flag1) { renderer.clearOverrideBlockTexture(); } tessellator.setBrightness( par1Block.getMixedBrightnessForBlock(renderer.blockAccess, par2, par3, par4)); float f3 = 1.0F; if (Block.lightValue[par1Block.blockID] > 0) { f3 = 1.0F; } tessellator.setColorOpaque_F(f3, f3, f3); Icon icon = renderer.getBlockIconFromSide(par1Block, 0); if (renderer.hasOverrideBlockTexture()) { icon = renderer.overrideBlockTexture; } double d0 = (double) icon.getMinU(); double d1 = (double) icon.getMinV(); double d2 = (double) icon.getMaxU(); double d3 = (double) icon.getMaxV(); Vec3[] avec3 = new Vec3[8]; float f4 = 0.0625F; float f5 = 0.0625F; float f6 = 0.625F; avec3[0] = renderer .blockAccess .getWorldVec3Pool() .getVecFromPool((double) (-f4), 0.0D, (double) (-f5)); avec3[1] = renderer.blockAccess.getWorldVec3Pool().getVecFromPool((double) f4, 0.0D, (double) (-f5)); avec3[2] = renderer.blockAccess.getWorldVec3Pool().getVecFromPool((double) f4, 0.0D, (double) f5); avec3[3] = renderer.blockAccess.getWorldVec3Pool().getVecFromPool((double) (-f4), 0.0D, (double) f5); avec3[4] = renderer .blockAccess .getWorldVec3Pool() .getVecFromPool((double) (-f4), (double) f6, (double) (-f5)); avec3[5] = renderer .blockAccess .getWorldVec3Pool() .getVecFromPool((double) f4, (double) f6, (double) (-f5)); avec3[6] = renderer .blockAccess .getWorldVec3Pool() .getVecFromPool((double) f4, (double) f6, (double) f5); avec3[7] = renderer .blockAccess .getWorldVec3Pool() .getVecFromPool((double) (-f4), (double) f6, (double) f5); for (int j1 = 0; j1 < 8; ++j1) { if (flag) { avec3[j1].zCoord -= 0.0625D; avec3[j1].rotateAroundX(((float) Math.PI * 2F / 9F)); } else { avec3[j1].zCoord += 0.0625D; avec3[j1].rotateAroundX(-((float) Math.PI * 2F / 9F)); } if (i1 == 0 || i1 == 7) { avec3[j1].rotateAroundZ((float) Math.PI); } if (i1 == 6 || i1 == 0) { avec3[j1].rotateAroundY(((float) Math.PI / 2F)); } if (i1 > 0 && i1 < 5) { avec3[j1].yCoord -= 0.375D; avec3[j1].rotateAroundX(((float) Math.PI / 2F)); if (i1 == 4) { avec3[j1].rotateAroundY(0.0F); } if (i1 == 3) { avec3[j1].rotateAroundY((float) Math.PI); } if (i1 == 2) { avec3[j1].rotateAroundY(((float) Math.PI / 2F)); } if (i1 == 1) { avec3[j1].rotateAroundY(-((float) Math.PI / 2F)); } avec3[j1].xCoord += (double) par2 + 0.5D; avec3[j1].yCoord += (double) ((float) par3 + 0.5F); avec3[j1].zCoord += (double) par4 + 0.5D; } else if (i1 != 0 && i1 != 7) { avec3[j1].xCoord += (double) par2 + 0.5D; avec3[j1].yCoord += (double) ((float) par3 + 0.125F); avec3[j1].zCoord += (double) par4 + 0.5D; } else { avec3[j1].xCoord += (double) par2 + 0.5D; avec3[j1].yCoord += (double) ((float) par3 + 0.875F); avec3[j1].zCoord += (double) par4 + 0.5D; } } Vec3 vec3 = null; Vec3 vec31 = null; Vec3 vec32 = null; Vec3 vec33 = null; for (int k1 = 0; k1 < 6; ++k1) { if (k1 == 0) { d0 = (double) icon.getInterpolatedU(7.0D); d1 = (double) icon.getInterpolatedV(6.0D); d2 = (double) icon.getInterpolatedU(9.0D); d3 = (double) icon.getInterpolatedV(8.0D); } else if (k1 == 2) { d0 = (double) icon.getInterpolatedU(7.0D); d1 = (double) icon.getInterpolatedV(6.0D); d2 = (double) icon.getInterpolatedU(9.0D); d3 = (double) icon.getMaxV(); } if (k1 == 0) { vec3 = avec3[0]; vec31 = avec3[1]; vec32 = avec3[2]; vec33 = avec3[3]; } else if (k1 == 1) { vec3 = avec3[7]; vec31 = avec3[6]; vec32 = avec3[5]; vec33 = avec3[4]; } else if (k1 == 2) { vec3 = avec3[1]; vec31 = avec3[0]; vec32 = avec3[4]; vec33 = avec3[5]; } else if (k1 == 3) { vec3 = avec3[2]; vec31 = avec3[1]; vec32 = avec3[5]; vec33 = avec3[6]; } else if (k1 == 4) { vec3 = avec3[3]; vec31 = avec3[2]; vec32 = avec3[6]; vec33 = avec3[7]; } else if (k1 == 5) { vec3 = avec3[0]; vec31 = avec3[3]; vec32 = avec3[7]; vec33 = avec3[4]; } tessellator.addVertexWithUV(vec3.xCoord, vec3.yCoord, vec3.zCoord, d0, d3); tessellator.addVertexWithUV(vec31.xCoord, vec31.yCoord, vec31.zCoord, d2, d3); tessellator.addVertexWithUV(vec32.xCoord, vec32.yCoord, vec32.zCoord, d2, d1); tessellator.addVertexWithUV(vec33.xCoord, vec33.yCoord, vec33.zCoord, d0, d1); } } return true; }
/** Renders thin-profile crossed squares (reeds, vine-type blocks). */ public static void renderPlantThinCrossedSquares( RenderBlocks renderBlocks, Block block, int metadata, int x, int y, int z, boolean flipped) { Tessellator tessellator = Tessellator.instance; tessellator.setBrightness(block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y, z)); Icon icon = FlowerPotHandler.getPlantIcon(new ItemStack(block, 1, metadata)); setPlantColor(block, x, y, z); double uMin = icon.getInterpolatedU(0.0D); double uMax = icon.getInterpolatedU(4.0D); double vMin = icon.getInterpolatedV(16.0D); double vMax = icon.getInterpolatedV(0.0D); double rotatedScaleFactor = 0.45D * 0.375F; double xMin = x + 0.5D - rotatedScaleFactor; double xMax = x + 0.5D + rotatedScaleFactor; double zMin = z + 0.5D - rotatedScaleFactor; double zMax = z + 0.5D + rotatedScaleFactor; if (flipped) { double temp = vMin; vMin = vMax; vMax = temp; } tessellator.addVertexWithUV(xMin, y + 0.75D, zMin, uMin, vMax); tessellator.addVertexWithUV(xMin, y + 0.0D, zMin, uMin, vMin); tessellator.addVertexWithUV(x + 0.5D, y + 0.0D, z + 0.5D, uMax, vMin); tessellator.addVertexWithUV(x + 0.5D, y + 0.75D, z + 0.5D, uMax, vMax); tessellator.addVertexWithUV(xMax, y + 0.75D, zMin, uMin, vMax); tessellator.addVertexWithUV(xMax, y + 0.0D, zMin, uMin, vMin); tessellator.addVertexWithUV(x + 0.5D, y + 0.0D, z + 0.5D, uMax, vMin); tessellator.addVertexWithUV(x + 0.5D, y + 0.75D, z + 0.5D, uMax, vMax); tessellator.addVertexWithUV(xMax, y + 0.75D, zMax, uMin, vMax); tessellator.addVertexWithUV(xMax, y + 0.0D, zMax, uMin, vMin); tessellator.addVertexWithUV(x + 0.5D, y + 0.0D, z + 0.5D, uMax, vMin); tessellator.addVertexWithUV(x + 0.5D, y + 0.75D, z + 0.5D, uMax, vMax); tessellator.addVertexWithUV(xMin, y + 0.75D, zMax, uMin, vMax); tessellator.addVertexWithUV(xMin, y + 0.0D, zMax, uMin, vMin); tessellator.addVertexWithUV(x + 0.5D, y + 0.0D, z + 0.5D, uMax, vMin); tessellator.addVertexWithUV(x + 0.5D, y + 0.75D, z + 0.5D, uMax, vMax); uMin = icon.getInterpolatedU(12.0D); uMax = icon.getInterpolatedU(16.0D); tessellator.addVertexWithUV(x + 0.5D, y + 0.75D, z + 0.5D, uMin, vMax); tessellator.addVertexWithUV(x + 0.5D, y + 0.0D, z + 0.5D, uMin, vMin); tessellator.addVertexWithUV(xMin, y + 0.0D, zMin, uMax, vMin); tessellator.addVertexWithUV(xMin, y + 0.75D, zMin, uMax, vMax); tessellator.addVertexWithUV(x + 0.5D, y + 0.75D, z + 0.5D, uMin, vMax); tessellator.addVertexWithUV(x + 0.5D, y + 0.0D, z + 0.5D, uMin, vMin); tessellator.addVertexWithUV(xMax, y + 0.0D, zMin, uMax, vMin); tessellator.addVertexWithUV(xMax, y + 0.75D, zMin, uMax, vMax); tessellator.addVertexWithUV(x + 0.5D, y + 0.75D, z + 0.5D, uMin, vMax); tessellator.addVertexWithUV(x + 0.5D, y + 0.0D, z + 0.5D, uMin, vMin); tessellator.addVertexWithUV(xMax, y + 0.0D, zMax, uMax, vMin); tessellator.addVertexWithUV(xMax, y + 0.75D, zMax, uMax, vMax); tessellator.addVertexWithUV(x + 0.5D, y + 0.75D, z + 0.5D, uMin, vMax); tessellator.addVertexWithUV(x + 0.5D, y + 0.0D, z + 0.5D, uMin, vMin); tessellator.addVertexWithUV(xMin, y + 0.0D, zMax, uMax, vMin); tessellator.addVertexWithUV(xMin, y + 0.75D, zMax, uMax, vMax); }