Java Code Examples for net.minecraft.client.renderer.block.model.BakedQuad#hasTintIndex()
The following examples show how to use
net.minecraft.client.renderer.block.model.BakedQuad#hasTintIndex() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderUtils.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
/** * Reimplement vanilla item so we can draw pearl stacks with opacity support. * + FIX THE OPACITY RENDERING. */ private static void renderQuads(BufferBuilder renderer, List<BakedQuad> quads, int color, ItemStack stack) { color &= 0xFF000000; boolean flag = !stack.isEmpty(); int i = 0; for (int j = quads.size(); i < j; ++i) { BakedQuad bakedquad = quads.get(i); int k = color | 0xFFFFFF; if (flag && bakedquad.hasTintIndex()) { k = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, bakedquad.getTintIndex()); if (EntityRenderer.anaglyphEnable) { k = TextureUtil.anaglyphColor(k); } k &= 0xFFFFFF; k |= color; } LightUtil.renderQuadColor(renderer, bakedquad, k); } }
Example 2
Source File: BlockModelRendererSchematic.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
private void renderQuadsSmooth(IBlockAccess blockAccessIn, IBlockState stateIn, BlockPos posIn, BufferBuilder buffer, List<BakedQuad> list, float[] quadBounds, BitSet bitSet, AmbientOcclusionFace aoFace) { Vec3d vec3d = stateIn.getOffset(blockAccessIn, posIn); double x = (double)posIn.getX() + vec3d.x; double y = (double)posIn.getY() + vec3d.y; double z = (double)posIn.getZ() + vec3d.z; int i = 0; for (int j = list.size(); i < j; ++i) { BakedQuad bakedquad = list.get(i); this.fillQuadBounds(stateIn, bakedquad.getVertexData(), bakedquad.getFace(), quadBounds, bitSet); aoFace.updateVertexBrightness(blockAccessIn, stateIn, posIn, bakedquad.getFace(), quadBounds, bitSet); buffer.addVertexData(bakedquad.getVertexData()); buffer.putBrightness4(aoFace.vertexBrightness[0], aoFace.vertexBrightness[1], aoFace.vertexBrightness[2], aoFace.vertexBrightness[3]); if (bakedquad.hasTintIndex()) { int k = this.blockColors.colorMultiplier(stateIn, blockAccessIn, posIn, bakedquad.getTintIndex()); if (EntityRenderer.anaglyphEnable) { k = TextureUtil.anaglyphColor(k); } float f = (float)(k >> 16 & 255) / 255.0F; float f1 = (float)(k >> 8 & 255) / 255.0F; float f2 = (float)(k & 255) / 255.0F; buffer.putColorMultiplier(aoFace.vertexColorMultiplier[0] * f, aoFace.vertexColorMultiplier[0] * f1, aoFace.vertexColorMultiplier[0] * f2, 4); buffer.putColorMultiplier(aoFace.vertexColorMultiplier[1] * f, aoFace.vertexColorMultiplier[1] * f1, aoFace.vertexColorMultiplier[1] * f2, 3); buffer.putColorMultiplier(aoFace.vertexColorMultiplier[2] * f, aoFace.vertexColorMultiplier[2] * f1, aoFace.vertexColorMultiplier[2] * f2, 2); buffer.putColorMultiplier(aoFace.vertexColorMultiplier[3] * f, aoFace.vertexColorMultiplier[3] * f1, aoFace.vertexColorMultiplier[3] * f2, 1); } else { buffer.putColorMultiplier(aoFace.vertexColorMultiplier[0], aoFace.vertexColorMultiplier[0], aoFace.vertexColorMultiplier[0], 4); buffer.putColorMultiplier(aoFace.vertexColorMultiplier[1], aoFace.vertexColorMultiplier[1], aoFace.vertexColorMultiplier[1], 3); buffer.putColorMultiplier(aoFace.vertexColorMultiplier[2], aoFace.vertexColorMultiplier[2], aoFace.vertexColorMultiplier[2], 2); buffer.putColorMultiplier(aoFace.vertexColorMultiplier[3], aoFace.vertexColorMultiplier[3], aoFace.vertexColorMultiplier[3], 1); } buffer.putPosition(x, y, z); } }
Example 3
Source File: BlockModelRendererSchematic.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
private void renderQuadsFlat(IBlockAccess blockAccessIn, IBlockState stateIn, BlockPos posIn, int brightnessIn, boolean ownBrightness, BufferBuilder buffer, List<BakedQuad> list, BitSet bitSet) { Vec3d vec3d = stateIn.getOffset(blockAccessIn, posIn); double d0 = (double)posIn.getX() + vec3d.x; double d1 = (double)posIn.getY() + vec3d.y; double d2 = (double)posIn.getZ() + vec3d.z; int i = 0; for (int j = list.size(); i < j; ++i) { BakedQuad bakedquad = list.get(i); if (ownBrightness) { this.fillQuadBounds(stateIn, bakedquad.getVertexData(), bakedquad.getFace(), (float[])null, bitSet); BlockPos blockpos = bitSet.get(0) ? posIn.offset(bakedquad.getFace()) : posIn; brightnessIn = stateIn.getPackedLightmapCoords(blockAccessIn, blockpos); } buffer.addVertexData(bakedquad.getVertexData()); buffer.putBrightness4(brightnessIn, brightnessIn, brightnessIn, brightnessIn); if (bakedquad.hasTintIndex()) { int k = this.blockColors.colorMultiplier(stateIn, blockAccessIn, posIn, bakedquad.getTintIndex()); if (EntityRenderer.anaglyphEnable) { k = TextureUtil.anaglyphColor(k); } float f = (float)(k >> 16 & 255) / 255.0F; float f1 = (float)(k >> 8 & 255) / 255.0F; float f2 = (float)(k & 255) / 255.0F; buffer.putColorMultiplier(f, f1, f2, 4); buffer.putColorMultiplier(f, f1, f2, 3); buffer.putColorMultiplier(f, f1, f2, 2); buffer.putColorMultiplier(f, f1, f2, 1); } buffer.putPosition(d0, d1, d2); } }
Example 4
Source File: RenderUtils.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
/** * Reimplement vanilla item so we can draw pearl stacks with opacity support. */ private static void renderLitItem(RenderItem ri, IBakedModel model, int color, ItemStack stack) { List<BakedQuad> allquads = new ArrayList<>(); for (EnumFacing enumfacing : EnumFacing.VALUES) { allquads.addAll(model.getQuads(null, enumfacing, 0)); } allquads.addAll(model.getQuads(null, null, 0)); if (allquads.isEmpty()) return; // Current list of consecutive quads with the same lighting List<BakedQuad> segment = new ArrayList<>(); // Lighting of the current segment int segmentBlockLight = -1; int segmentSkyLight = -1; // Coloring of the current segment int segmentColorMultiplier = color; // If the current segment contains lighting data boolean hasLighting = false; // Tint index cache to avoid unnecessary IItemColor lookups int prevTintIndex = -1; for (int i = 0; i < allquads.size(); i++) { BakedQuad q = allquads.get(i); // Lighting of the current quad int bl = 0; int sl = 0; // Fail-fast on ITEM, as it cannot have light data if (q.getFormat() != DefaultVertexFormats.ITEM && q.getFormat().hasUvOffset(1)) { q.pipe(lightGatherer); if (lightGatherer.hasLighting()) { bl = lightGatherer.blockLight; sl = lightGatherer.skyLight; } } int colorMultiplier = segmentColorMultiplier; // If there is no color override, and this quad is tinted, we need to apply IItemColor if (color == 0xFFFFFFFF && q.hasTintIndex()) { int tintIndex = q.getTintIndex(); if (prevTintIndex != tintIndex) { colorMultiplier = getColorMultiplier(stack, tintIndex); } prevTintIndex = tintIndex; } else { colorMultiplier = color; prevTintIndex = -1; } boolean lightingDirty = segmentBlockLight != bl || segmentSkyLight != sl; boolean colorDirty = hasLighting && segmentColorMultiplier != colorMultiplier; // If lighting or color data has changed, draw the segment and flush it if (lightingDirty || colorDirty) { if (i > 0) // Make sure this isn't the first quad being processed { drawSegment(color, stack, segment, segmentBlockLight, segmentSkyLight, segmentColorMultiplier, lightingDirty && (hasLighting || segment.size() < i), colorDirty); } segmentBlockLight = bl; segmentSkyLight = sl; segmentColorMultiplier = colorMultiplier; hasLighting = segmentBlockLight > 0 || segmentSkyLight > 0; } segment.add(q); } drawSegment(color, stack, segment, segmentBlockLight, segmentSkyLight, segmentColorMultiplier, hasLighting || segment.size() < allquads.size(), false); // Clean up render state if necessary if (hasLighting) { OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, OpenGlHelper.lastBrightnessX, OpenGlHelper.lastBrightnessY); GL11.glMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_EMISSION, RenderHelper.setColorBuffer(0, 0, 0, 1)); } }