private DisplayInteger[] getListAndRender(RenderData data, Fluid fluid, World world) { if (cachedCenterFluids.containsKey(data) && cachedCenterFluids.get(data).containsKey(fluid)) { return cachedCenterFluids.get(data).get(fluid); } Model3D toReturn = new Model3D(); toReturn.baseBlock = Blocks.water; toReturn.setTexture(fluid.getIcon()); final int stages = getStages(data.height); DisplayInteger[] displays = new DisplayInteger[stages]; if (cachedCenterFluids.containsKey(data)) { cachedCenterFluids.get(data).put(fluid, displays); } else { HashMap<Fluid, DisplayInteger[]> map = new HashMap<Fluid, DisplayInteger[]>(); map.put(fluid, displays); cachedCenterFluids.put(data, map); } for (int i = 0; i < stages; i++) { displays[i] = DisplayInteger.createAndStart(); if (fluid.getIcon() != null) { toReturn.minX = 0 + .01; toReturn.minY = 0 + .01; toReturn.minZ = 0 + .01; toReturn.maxX = data.length - .01; toReturn.maxY = ((float) i / (float) stages) * (data.height - 2) - .01; toReturn.maxZ = data.width - .01; MekanismRenderer.renderObject(toReturn); } GL11.glEndList(); } return displays; }
private void renderLiquid(TileEntity tile, double par2, double par4, double par6) { GL11.glTranslated(par2, par4, par6); TileEntityFillingStation tr = (TileEntityFillingStation) tile; double dx = 0; double dz = 0; double ddx = 0; double ddz = 0; switch (tr.getBlockMetadata()) { case 0: dx = 0.25; break; case 1: ddx = 0.25; break; case 2: dz = 0.25; break; case 3: ddz = 0.25; break; } if (!tr.isEmpty() && tr.isInWorld()) { Fluid f = tr.getFluid(); if (!f.equals(FluidRegistry.LAVA)) { GL11.glEnable(GL11.GL_BLEND); } ReikaLiquidRenderer.bindFluidTexture(f); IIcon ico = f.getIcon(); float u = ico.getMinU(); float v = ico.getMinV(); float du = ico.getMaxU(); float dv = ico.getMaxV(); double h = 0.0625 + 14D / 16D * tr.getLevel() / tr.CAPACITY; Tessellator v5 = Tessellator.instance; if (f.getLuminosity() > 0) ReikaRenderHelper.disableLighting(); v5.startDrawingQuads(); v5.setNormal(0, 1, 0); v5.addVertexWithUV(dx + 0, h, -ddz + 1, u, dv); v5.addVertexWithUV(-ddx + 1, h, -ddz + 1, du, dv); v5.addVertexWithUV(-ddx + 1, h, dz + 0, du, v); v5.addVertexWithUV(dx + 0, h, dz + 0, u, v); v5.draw(); ReikaRenderHelper.enableLighting(); } GL11.glTranslated(-par2, -par4, -par6); GL11.glDisable(GL11.GL_BLEND); }
private void drawFluids(int recipe) { CentrifugeRecipe r = (CentrifugeRecipe) arecipes.get(recipe); ItemStack in = r.input; FluidStack fs = RecipesCentrifuge.getRecipes().getFluidResult(in); if (fs != null) { Fluid f = fs.getFluid(); IIcon ico = f.getIcon(); float u = ico.getMinU(); float v = ico.getMinV(); float du = ico.getMaxU(); float dv = ico.getMaxV(); ReikaTextureHelper.bindTerrainTexture(); Tessellator v5 = Tessellator.instance; v5.startDrawingQuads(); int x = 147; for (int i = 0; i < 4; i++) { int y = 1 + i * 16; v5.addVertexWithUV(x, y, 0, u, v); v5.addVertexWithUV(x, y + 16, 0, u, dv); v5.addVertexWithUV(x + 16, y + 16, 0, du, dv); v5.addVertexWithUV(x + 16, y, 0, du, v); } v5.addVertexWithUV(x, 65, 0, u, v); v5.addVertexWithUV(x, 68, 0, u, dv); v5.addVertexWithUV(x + 16, 68, 0, du, dv); v5.addVertexWithUV(x + 16, 65, 0, du, v); v5.draw(); FontRenderer fr = Minecraft.getMinecraft().fontRenderer; String s = f.getLocalizedName() + " (" + fs.amount + " mB) (" + RecipesCentrifuge.getRecipes().getFluidChance(in) + "%)"; int l = fr.getStringWidth(s); fr.drawString(s, 166 - l, 70, 0); } }
public static void drawLiquidBar( int x, int y, int width, int height, int fluidID, int percentage) { Fluid fluid = FluidRegistry.getFluid(fluidID); if (fluid == null) return; Icon icon = fluid.getIcon(); if (icon == null) return; // Bind SpriteNumber=0,texture "/terrain.png" TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); texturemanager.bindTexture(texturemanager.getResourceLocation(0)); double u = icon.getInterpolatedU(3.0D); double u2 = icon.getInterpolatedU(13.0D); double v = icon.getInterpolatedV(1.0D); double v2 = icon.getInterpolatedV(15.0D); int z = height * percentage / 100; GL11.glEnable(3553); GL11.glColor4d(1.0D, 1.0D, 1.0D, 1.0D); GL11.glBegin(7); GL11.glTexCoord2d(u, v); GL11.glVertex2i(x, y + height - z); GL11.glTexCoord2d(u, v2); GL11.glVertex2i(x, y + height); GL11.glTexCoord2d(u2, v2); GL11.glVertex2i(x + width, y + height); GL11.glTexCoord2d(u2, v); GL11.glVertex2i(x + width, y + height - z); GL11.glEnd(); }
@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 void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) { TilePipe tp = (TilePipe) te; int lvl = tp.pipebuf.getLevel(); if (tp.pipebuf.Type != 0 && lvl > 0) { float lvn = Math.min(1.0F, (float) lvl / (float) tp.pipebuf.getMaxLevel()); tp.cacheCon(); int sides = tp.ConCache; Fluid fcl = FluidRegistry.getFluid(tp.pipebuf.Type); if (fcl != null) { Tessellator tessellator = Tessellator.instance; // this.bindTextureByName(fcl.getTextureFile()); int lv = te.getWorldObj().getLightBrightnessForSkyBlocks(te.xCoord, te.yCoord, te.zCoord, 0); GL11.glEnable(3042); GL11.glBlendFunc(770, 771); GL11.glDisable(2896); tessellator.startDrawingQuads(); this.context.setBrightness(lv); this.context.setPos(x, y, z); this.context.setIcon(fcl.getIcon()); float x1; float x2; float n; if ((sides & 3) > 0) { x1 = 0.5F; x2 = 0.5F; if ((sides & 1) > 0) { x1 = 0.0F; } if ((sides & 2) > 0) { x2 = 1.0F; } n = 0.124F * lvn; this.context.renderBox(60, 0.5F - n, x1, 0.5F - n, 0.5F + n, x2, 0.5F + n); } if ((sides & 12) > 0) { x1 = 0.5F; x2 = 0.5F; if ((sides & 4) > 0) { x1 = 0.0F; } if ((sides & 8) > 0) { x2 = 1.0F; } n = 0.248F * lvn; this.context.renderBox( 51, 0.37599998712539673D, 0.37599998712539673D, x1, 0.6240000128746033D, 0.376F + n, x2); } if ((sides & 48) > 0) { x1 = 0.5F; x2 = 0.5F; if ((sides & 16) > 0) { x1 = 0.0F; } if ((sides & 32) > 0) { x2 = 1.0F; } n = 0.248F * lvn; this.context.renderBox( 15, x1, 0.37599998712539673D, 0.37599998712539673D, x2, 0.376F + n, 0.6240000128746033D); } tessellator.draw(); GL11.glEnable(2896); GL11.glDisable(3042); } } }
@SuppressWarnings("incomplete-switch") private DisplayInteger[] getListAndRender(SalinationRenderData data, Fluid fluid) { if (cachedCenterFluids.containsKey(data) && cachedCenterFluids.get(data).containsKey(fluid)) { return cachedCenterFluids.get(data).get(fluid); } Model3D toReturn = new Model3D(); toReturn.baseBlock = Block.waterStill; toReturn.setTexture(fluid.getIcon()); final int stages = getStages(data.height); DisplayInteger[] displays = new DisplayInteger[stages]; if (cachedCenterFluids.containsKey(data)) { cachedCenterFluids.get(data).put(fluid, displays); } else { HashMap<Fluid, DisplayInteger[]> map = new HashMap<Fluid, DisplayInteger[]>(); map.put(fluid, displays); cachedCenterFluids.put(data, map); } MekanismRenderer.colorFluid(fluid); for (int i = 0; i < stages; i++) { displays[i] = DisplayInteger.createAndStart(); if (fluid.getIcon() != null) { switch (data.side) { case NORTH: toReturn.minX = 0 + .01; toReturn.minY = 0 + .01; toReturn.minZ = 0 + .01; toReturn.maxX = 2 - .01; toReturn.maxY = ((float) i / (float) stages) * data.height - .01; toReturn.maxZ = 2 - .01; break; case SOUTH: toReturn.minX = -1 + .01; toReturn.minY = 0 + .01; toReturn.minZ = -1 + .01; toReturn.maxX = 1 - .01; toReturn.maxY = ((float) i / (float) stages) * data.height - .01; toReturn.maxZ = 1 - .01; break; case WEST: toReturn.minX = 0 + .01; toReturn.minY = 0 + .01; toReturn.minZ = -1 + .01; toReturn.maxX = 2 - .01; toReturn.maxY = ((float) i / (float) stages) * data.height - .01; toReturn.maxZ = 1 - .01; break; case EAST: toReturn.minX = -1 + .01; toReturn.minY = 0 + .01; toReturn.minZ = 0 + .01; toReturn.maxX = 1 - .01; toReturn.maxY = ((float) i / (float) stages) * data.height - .01; toReturn.maxZ = 2 - .01; break; } MekanismRenderer.renderObject(toReturn); } displays[i].endList(); } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); return displays; }