Java Code Examples for net.minecraft.client.renderer.Tessellator#setBrightness()

The following examples show how to use net.minecraft.client.renderer.Tessellator#setBrightness() . 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: FXFlow.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void renderEssenceBase(Tessellator tessellator) {
    tessellator.setBrightness(rendBrightness);
    GL11.glColor4f(partRed , partGreen, partBlue, partAlpha);
    Minecraft.getMinecraft().renderEngine.bindTexture(texture);
    if(particleAge >= particleMaxAge) return;
    float agescale = (float) particleAge / buffHalfLife;
    if(agescale >= 1.0F) agescale = 2 - agescale;
    particleScale = buffParticleScale * agescale;
    float f10 = 0.5F * particleScale;
    float f11 = (float)(prevPosX + (posX - prevPosX) * partialTicks - interpPosX);
    float f12 = (float)(prevPosY + (posY - prevPosY) * partialTicks - interpPosY);
    float f13 = (float)(prevPosZ + (posZ - prevPosZ) * partialTicks - interpPosZ);

    tessellator.addVertexWithUV(f11 - rendArg1 * f10 - rendArg4 * f10, f12 - rendArg2 * f10, f13 - rendArg3 * f10 - rendArg5 * f10, 0, 1);
    tessellator.addVertexWithUV(f11 - rendArg1 * f10 + rendArg4 * f10, f12 + rendArg2 * f10, f13 - rendArg3 * f10 + rendArg5 * f10, 1, 1);
    tessellator.addVertexWithUV(f11 + rendArg1 * f10 + rendArg4 * f10, f12 + rendArg2 * f10, f13 + rendArg3 * f10 + rendArg5 * f10, 1, 0);
    tessellator.addVertexWithUV(f11 + rendArg1 * f10 - rendArg4 * f10, f12 - rendArg2 * f10, f13 + rendArg3 * f10 - rendArg5 * f10, 0, 0);
}
 
Example 2
Source File: RenderHelperLL.java    From GardenCollection with MIT License 6 votes vote down vote up
private void renderXYZUVAO (int[][] index) {
    Tessellator tessellator = Tessellator.instance;

    int[] tl = index[TL];
    int[] bl = index[BL];
    int[] br = index[BR];
    int[] tr = index[TR];

    tessellator.setColorOpaque_F(state.colorTopLeft[0], state.colorTopLeft[1], state.colorTopLeft[2]);
    tessellator.setBrightness(state.brightnessTopLeft);
    tessellator.addVertexWithUV(xyz[tl[0]], xyz[tl[1]], xyz[tl[2]], uv[tl[3]], uv[tl[4]]);

    tessellator.setColorOpaque_F(state.colorBottomLeft[0], state.colorBottomLeft[1], state.colorBottomLeft[2]);
    tessellator.setBrightness(state.brightnessBottomLeft);
    tessellator.addVertexWithUV(xyz[bl[0]], xyz[bl[1]], xyz[bl[2]], uv[bl[3]], uv[bl[4]]);

    tessellator.setColorOpaque_F(state.colorBottomRight[0], state.colorBottomRight[1], state.colorBottomRight[2]);
    tessellator.setBrightness(state.brightnessBottomRight);
    tessellator.addVertexWithUV(xyz[br[0]], xyz[br[1]], xyz[br[2]], uv[br[3]], uv[br[4]]);

    tessellator.setColorOpaque_F(state.colorTopRight[0], state.colorTopRight[1], state.colorTopRight[2]);
    tessellator.setBrightness(state.brightnessTopRight);
    tessellator.addVertexWithUV(xyz[tr[0]], xyz[tr[1]], xyz[tr[2]], uv[tr[3]], uv[tr[4]]);
}
 
Example 3
Source File: RenderHelper.java    From GardenCollection with MIT License 5 votes vote down vote up
private void setupColorMult (int face, IBlockAccess blockAccess, Block block, int x, int y, int z, float r, float g, float b) {
    Tessellator tessellator = Tessellator.instance;
    float[] norm = normMap[face];
    float scale = state.getColorMult(face);

    if (blockAccess == null) {
        tessellator.startDrawingQuads();
        tessellator.setColorOpaque_F(r, g, b);
        tessellator.setNormal(norm[0], norm[1], norm[2]);
    }
    else {
        int brightX = x;
        int brightY = y;
        int brightZ = z;

        switch (face) {
            case YNEG: brightY = (state.renderMinY > 0) ? y : y - 1; break;
            case YPOS: brightY = (state.renderMaxY < 1) ? y : y + 1; break;
            case ZNEG: brightZ = (state.renderMinZ > 0) ? z : z - 1; break;
            case ZPOS: brightZ = (state.renderMaxZ < 1) ? z : z + 1; break;
            case XNEG: brightX = (state.renderMinX > 0) ? x : x - 1; break;
            case XPOS: brightX = (state.renderMaxX < 1) ? x : x + 1; break;
        }

        tessellator.setColorOpaque_F(scale * r, scale * g, scale * b);
        tessellator.setBrightness(block.getMixedBrightnessForBlock(blockAccess, brightX, brightY, brightZ));
    }

    state.enableAO = false;
}
 
Example 4
Source File: RenderLaserSource.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	int l = 1;
	if(world != null)
		l = world.getBlockMetadata(x, y, z);
	IIcon laser = block.getIcon(0,0);
	Tessellator tessellator = Tessellator.instance;
	tessellator.setBrightness(15728880);
	tessellator.setColorOpaque_F(1, 1, 1);
       float f = 1F - 1F/128F;
       renderer.renderMaxX = 1;
       renderer.renderMinX = 0;
       renderer.renderMaxY = 1;
       renderer.renderMinY = 0;
       renderer.renderMaxZ = 1;
       renderer.renderMinZ = 0;
	switch(l&3) {
		case 0:
			renderer.renderFaceZPos(Blocks.ice, x, y, z-f, laser);
			break;
		case 1:
			renderer.renderFaceXNeg(Blocks.ice, x+f, y, z, laser);
			break;
		case 2:
			renderer.renderFaceZNeg(Blocks.ice, x, y, z+f, laser);
			break;
		case 3:
			renderer.renderFaceXPos(Blocks.ice, x-f, y, z, laser);
			break;
	}
	if(world != null)
		renderer.renderBlockAllFaces(BlockLaserBeam.instance, x, y, z);
	return true;
}
 
Example 5
Source File: RenderHelper.java    From GardenCollection with MIT License 5 votes vote down vote up
public void renderCrossedSquares (IBlockAccess blockAccess, Block block, int x, int y, int z, IIcon icon) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z));

    calculateBaseColor(colorScratch, block.colorMultiplier(blockAccess, x, y, z));
    setTessellatorColor(tessellator, colorScratch);

    drawCrossedSquares(icon, x, y, z, 1.0F);
}
 
Example 6
Source File: RenderHelperAO.java    From GardenCollection with MIT License 4 votes vote down vote up
public void setupXPosAOPartial (IBlockAccess blockAccess, Block block, int x, int y, int z, float r, float g, float b) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(983055);

    int xGrass = (state.renderMaxX >= 1) ? x + 1 : x;

    boolean blocksGrassXYNP = !blockAccess.getBlock(xGrass, y + 1, z).getCanBlockGrass();
    boolean blocksGrassXYNN = !blockAccess.getBlock(xGrass, y - 1, z).getCanBlockGrass();
    boolean blocksGrassXZNN = !blockAccess.getBlock(xGrass, y, z - 1).getCanBlockGrass();
    boolean blocksGrassXZNP = !blockAccess.getBlock(xGrass, y, z + 1).getCanBlockGrass();

    if (state.renderMaxX < 1)
        setupAOBrightnessXPos(blockAccess, block, x, y, z, blocksGrassXYNP, blocksGrassXYNN, blocksGrassXZNN, blocksGrassXZNP);

    setupAOBrightnessXNeg(blockAccess, block, x + 1, y, z, blocksGrassXYNP, blocksGrassXYNN, blocksGrassXZNN, blocksGrassXZNP);

    float xClamp = MathHelper.clamp_float((float) state.renderMaxX, 0, 1);
    mixAOBrightnessLightValueX(xClamp, 1 - xClamp);

    int blockBrightness = block.getMixedBrightnessForBlock(blockAccess, x, y, z);
    if (state.renderMaxX >= 1.0D || !blockAccess.getBlock(x + 1, y, z).isOpaqueCube())
        blockBrightness = block.getMixedBrightnessForBlock(blockAccess, x + 1, y, z);

    float aoOpposingBlock = blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue();
    float aoXYZPNP = (aoLightValueScratchXYIN + aoLightValueScratchXYZINP + aoOpposingBlock + aoLightValueScratchXZIP) / 4.0F;
    float aoXYZPNN = (aoLightValueScratchXYZINN + aoLightValueScratchXYIN + aoLightValueScratchXZIN + aoOpposingBlock) / 4.0F;
    float aoXYZPPN = (aoLightValueScratchXZIN + aoOpposingBlock + aoLightValueScratchXYZIPN + aoLightValueScratchXYIP) / 4.0F;
    float aoXYZPPP = (aoOpposingBlock + aoLightValueScratchXZIP + aoLightValueScratchXYIP + aoLightValueScratchXYZIPP) / 4.0F;

    float aoTL = (float)((double)aoXYZPNP * (1.0D - state.renderMinY) * state.renderMaxZ + (double)aoXYZPNN * (1.0D - state.renderMinY) * (1.0D - state.renderMaxZ) + (double)aoXYZPPN * state.renderMinY * (1.0D - state.renderMaxZ) + (double)aoXYZPPP * state.renderMinY * state.renderMaxZ);
    float aoBL = (float)((double)aoXYZPNP * (1.0D - state.renderMinY) * state.renderMinZ + (double)aoXYZPNN * (1.0D - state.renderMinY) * (1.0D - state.renderMinZ) + (double)aoXYZPPN * state.renderMinY * (1.0D - state.renderMinZ) + (double)aoXYZPPP * state.renderMinY * state.renderMinZ);
    float aoBR = (float)((double)aoXYZPNP * (1.0D - state.renderMaxY) * state.renderMinZ + (double)aoXYZPNN * (1.0D - state.renderMaxY) * (1.0D - state.renderMinZ) + (double)aoXYZPPN * state.renderMaxY * (1.0D - state.renderMinZ) + (double)aoXYZPPP * state.renderMaxY * state.renderMinZ);
    float aoTR = (float)((double)aoXYZPNP * (1.0D - state.renderMaxY) * state.renderMaxZ + (double)aoXYZPNN * (1.0D - state.renderMaxY) * (1.0D - state.renderMaxZ) + (double)aoXYZPPN * state.renderMaxY * (1.0D - state.renderMaxZ) + (double)aoXYZPPP * state.renderMaxY * state.renderMaxZ);

    int brXYZPNP = getAOBrightness(aoBrightnessXYIN, aoBrightnessXYZINP, aoBrightnessXZIP, blockBrightness);
    int brXYZPNN = getAOBrightness(aoBrightnessXZIP, aoBrightnessXYIP, aoBrightnessXYZIPP, blockBrightness);
    int brXYZPPN = getAOBrightness(aoBrightnessXZIN, aoBrightnessXYZIPN, aoBrightnessXYIP, blockBrightness);
    int brXYZPPP = getAOBrightness(aoBrightnessXYZINN, aoBrightnessXYIN, aoBrightnessXZIN, blockBrightness);

    state.brightnessTopLeft = mixAOBrightness(brXYZPNP, brXYZPPP, brXYZPPN, brXYZPNN, (1.0D - state.renderMinY) * state.renderMaxZ, (1.0D - state.renderMinY) * (1.0D - state.renderMaxZ), state.renderMinY * (1.0D - state.renderMaxZ), state.renderMinY * state.renderMaxZ);
    state.brightnessBottomLeft = mixAOBrightness(brXYZPNP, brXYZPPP, brXYZPPN, brXYZPNN, (1.0D - state.renderMinY) * state.renderMinZ, (1.0D - state.renderMinY) * (1.0D - state.renderMinZ), state.renderMinY * (1.0D - state.renderMinZ), state.renderMinY * state.renderMinZ);
    state.brightnessBottomRight = mixAOBrightness(brXYZPNP, brXYZPPP, brXYZPPN, brXYZPNN, (1.0D - state.renderMaxY) * state.renderMinZ, (1.0D - state.renderMaxY) * (1.0D - state.renderMinZ), state.renderMaxY * (1.0D - state.renderMinZ), state.renderMaxY * state.renderMinZ);
    state.brightnessTopRight = mixAOBrightness(brXYZPNP, brXYZPPP, brXYZPPN, brXYZPNN, (1.0D - state.renderMaxY) * state.renderMaxZ, (1.0D - state.renderMaxY) * (1.0D - state.renderMaxZ), state.renderMaxY * (1.0D - state.renderMaxZ), state.renderMaxY * state.renderMaxZ);

    state.setColor(r * state.colorMultXPos, g * state.colorMultXPos, b * state.colorMultXPos);
    state.scaleColor(state.colorTopLeft, aoTL);
    state.scaleColor(state.colorBottomLeft, aoBL);
    state.scaleColor(state.colorBottomRight, aoBR);
    state.scaleColor(state.colorTopRight, aoTR);
}
 
Example 7
Source File: FXVortex.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void render(Tessellator tessellator, float pTicks) {
    float arX = ActiveRenderInfo.rotationX;
    float arXZ = ActiveRenderInfo.rotationXZ;
    float arZ = ActiveRenderInfo.rotationZ;
    float arYZ = ActiveRenderInfo.rotationYZ;
    float arXY = ActiveRenderInfo.rotationXY;

    GL11.glPushMatrix();
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    float agescale = (float) (ClientHandler.ticks % 800) / 400F;
    if(agescale >= 1.0F) agescale = 2 - agescale;
    float size = 0.2F + 0.1F * agescale;
    if(parent != null) {
        size += size * (((float) parent.getSizeStage()) * 0.04F);
    }

    float anglePerc = (float) (ClientHandler.ticks % 300) / 300F;
    float angle = RAD - RAD * anglePerc;

    Vector3 iV = MiscUtils.interpolateEntityPosition(Minecraft.getMinecraft().renderViewEntity, pTicks);
    if(parent != null && parent.getSizeStage() > 4) {
        float mult = 0.001F * (parent.getSizeStage() - 4F);
        Vector3 shake = new Vector3(
                RAND.nextFloat() * mult * (RAND.nextBoolean() ? 1 : -1),
                RAND.nextFloat() * mult * (RAND.nextBoolean() ? 1 : -1),
                RAND.nextFloat() * mult * (RAND.nextBoolean() ? 1 : -1));
        iV.add(shake);
    }

    GL11.glTranslated(-iV.getX(), -iV.getY(), -iV.getZ());

    UtilsFX.bindTexture(TC_VORTEX_TEXTURE);

    tessellator.startDrawingQuads();
    tessellator.setBrightness(220);
    tessellator.setColorRGBA_F(1F, 1F, 1F, 1F);

    Vec3 v1 = Vec3.createVectorHelper(-arX * size - arYZ * size, -arXZ * size, -arZ * size - arXY * size);
    Vec3 v2 = Vec3.createVectorHelper(-arX * size + arYZ * size, arXZ * size, -arZ * size + arXY * size);
    Vec3 v3 = Vec3.createVectorHelper(arX * size + arYZ * size, arXZ * size, arZ * size + arXY * size);
    Vec3 v4 = Vec3.createVectorHelper(arX * size - arYZ * size, -arXZ * size, arZ * size - arXY * size);
    if (angle != 0.0F) {
        Vec3 pvec = Vec3.createVectorHelper(iV.getX(), iV.getY(), iV.getZ());
        Vec3 tvec = Vec3.createVectorHelper(x, y, z);
        Vec3 qvec = pvec.subtract(tvec).normalize();
        QuadHelper.setAxis(qvec, angle).rotate(v1);
        QuadHelper.setAxis(qvec, angle).rotate(v2);
        QuadHelper.setAxis(qvec, angle).rotate(v3);
        QuadHelper.setAxis(qvec, angle).rotate(v4);
    }
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    tessellator.addVertexWithUV(x + v1.xCoord, y + v1.yCoord, z + v1.zCoord, 0, 1);
    tessellator.addVertexWithUV(x + v2.xCoord, y + v2.yCoord, z + v2.zCoord, 1, 1);
    tessellator.addVertexWithUV(x + v3.xCoord, y + v3.yCoord, z + v3.zCoord, 1, 0);
    tessellator.addVertexWithUV(x + v4.xCoord, y + v4.yCoord, z + v4.zCoord, 0, 0);
    tessellator.draw();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
    GL11.glPopMatrix();
}
 
Example 8
Source File: RenderHelperAO.java    From GardenCollection with MIT License 4 votes vote down vote up
public void setupXNegAOPartial (IBlockAccess blockAccess, Block block, int x, int y, int z, float r, float g, float b) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(983055);

    int xGrass = (state.renderMinX <= 0) ? x - 1 : x;

    boolean blocksGrassXYNP = !blockAccess.getBlock(xGrass, y + 1, z).getCanBlockGrass();
    boolean blocksGrassXYNN = !blockAccess.getBlock(xGrass, y - 1, z).getCanBlockGrass();
    boolean blocksGrassXZNN = !blockAccess.getBlock(xGrass, y, z - 1).getCanBlockGrass();
    boolean blocksGrassXZNP = !blockAccess.getBlock(xGrass, y, z + 1).getCanBlockGrass();

    if (state.renderMinX > 0)
        setupAOBrightnessXNeg(blockAccess, block, x, y, z, blocksGrassXYNP, blocksGrassXYNN, blocksGrassXZNN, blocksGrassXZNP);

    setupAOBrightnessXPos(blockAccess, block, x - 1, y, z, blocksGrassXYNP, blocksGrassXYNN, blocksGrassXZNN, blocksGrassXZNP);

    float xClamp = MathHelper.clamp_float((float) state.renderMinX, 0, 1);
    mixAOBrightnessLightValueX(xClamp, 1 - xClamp);

    int blockBrightness = block.getMixedBrightnessForBlock(blockAccess, x, y, z);
    if (state.renderMinX <= 0.0D || !blockAccess.getBlock(x - 1, y, z).isOpaqueCube())
        blockBrightness = block.getMixedBrightnessForBlock(blockAccess, x - 1, y, z);

    float aoOpposingBlock = blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue();
    float aoXYZNNP = (aoLightValueScratchXYIN + aoLightValueScratchXYZINP + aoOpposingBlock + aoLightValueScratchXZIP) / 4.0F;
    float aoXYZNPP = (aoOpposingBlock + aoLightValueScratchXZIP + aoLightValueScratchXYIP + aoLightValueScratchXYZIPP) / 4.0F;
    float aoXYZNPN = (aoLightValueScratchXZIN + aoOpposingBlock + aoLightValueScratchXYZIPN + aoLightValueScratchXYIP) / 4.0F;
    float aoXYZNNN = (aoLightValueScratchXYZINN + aoLightValueScratchXYIN + aoLightValueScratchXZIN + aoOpposingBlock) / 4.0F;

    float aoTL = (float)((double)aoXYZNPP * state.renderMaxY * state.renderMaxZ + (double)aoXYZNPN * state.renderMaxY * (1.0D - state.renderMaxZ) + (double)aoXYZNNN * (1.0D - state.renderMaxY) * (1.0D - state.renderMaxZ) + (double)aoXYZNNP * (1.0D - state.renderMaxY) * state.renderMaxZ);
    float aoBL = (float)((double)aoXYZNPP * state.renderMaxY * state.renderMinZ + (double)aoXYZNPN * state.renderMaxY * (1.0D - state.renderMinZ) + (double)aoXYZNNN * (1.0D - state.renderMaxY) * (1.0D - state.renderMinZ) + (double)aoXYZNNP * (1.0D - state.renderMaxY) * state.renderMinZ);
    float aoBR = (float)((double)aoXYZNPP * state.renderMinY * state.renderMinZ + (double)aoXYZNPN * state.renderMinY * (1.0D - state.renderMinZ) + (double)aoXYZNNN * (1.0D - state.renderMinY) * (1.0D - state.renderMinZ) + (double)aoXYZNNP * (1.0D - state.renderMinY) * state.renderMinZ);
    float aoTR = (float)((double)aoXYZNPP * state.renderMinY * state.renderMaxZ + (double)aoXYZNPN * state.renderMinY * (1.0D - state.renderMaxZ) + (double)aoXYZNNN * (1.0D - state.renderMinY) * (1.0D - state.renderMaxZ) + (double)aoXYZNNP * (1.0D - state.renderMinY) * state.renderMaxZ);

    int brXYZNNP = getAOBrightness(aoBrightnessXYIN, aoBrightnessXYZINP, aoBrightnessXZIP, blockBrightness);
    int brXYZNPP = getAOBrightness(aoBrightnessXZIP, aoBrightnessXYIP, aoBrightnessXYZIPP, blockBrightness);
    int brXYZNPN = getAOBrightness(aoBrightnessXZIN, aoBrightnessXYZIPN, aoBrightnessXYIP, blockBrightness);
    int brXYZNNN = getAOBrightness(aoBrightnessXYZINN, aoBrightnessXYIN, aoBrightnessXZIN, blockBrightness);

    state.brightnessTopLeft = mixAOBrightness(brXYZNPP, brXYZNPN, brXYZNNN, brXYZNNP, state.renderMaxY * state.renderMaxZ, state.renderMaxY * (1.0D - state.renderMaxZ), (1.0D - state.renderMaxY) * (1.0D - state.renderMaxZ), (1.0D - state.renderMaxY) * state.renderMaxZ);
    state.brightnessBottomLeft = mixAOBrightness(brXYZNPP, brXYZNPN, brXYZNNN, brXYZNNP, state.renderMaxY * state.renderMinZ, state.renderMaxY * (1.0D - state.renderMinZ), (1.0D - state.renderMaxY) * (1.0D - state.renderMinZ), (1.0D - state.renderMaxY) * state.renderMinZ);
    state.brightnessBottomRight = mixAOBrightness(brXYZNPP, brXYZNPN, brXYZNNN, brXYZNNP, state.renderMinY * state.renderMinZ, state.renderMinY * (1.0D - state.renderMinZ), (1.0D - state.renderMinY) * (1.0D - state.renderMinZ), (1.0D - state.renderMinY) * state.renderMinZ);
    state.brightnessTopRight = mixAOBrightness(brXYZNPP, brXYZNPN, brXYZNNN, brXYZNNP, state.renderMinY * state.renderMaxZ, state.renderMinY * (1.0D - state.renderMaxZ), (1.0D - state.renderMinY) * (1.0D - state.renderMaxZ), (1.0D - state.renderMinY) * state.renderMaxZ);

    state.setColor(r * state.colorMultXNeg, g * state.colorMultXNeg, b * state.colorMultXNeg);
    state.scaleColor(state.colorTopLeft, aoTL);
    state.scaleColor(state.colorBottomLeft, aoBL);
    state.scaleColor(state.colorBottomRight, aoBR);
    state.scaleColor(state.colorTopRight, aoTR);
}
 
Example 9
Source File: LightChainRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockLightChain block, int modelId, RenderBlocks renderer) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

    int color = block.colorMultiplier(world, x, y, z);
    float r = (float)(color >> 16 & 255) / 255f;
    float g = (float)(color >> 8 & 255) / 255f;
    float b = (float)(color & 255) / 255f;

    tessellator.setColorOpaque_F(r, g, b);

    IIcon icon = block.getIcon(0, world.getBlockMetadata(x, y, z));
    if (renderer.hasOverrideBlockTexture())
        icon = renderer.overrideBlockTexture;

    int yMin = block.findMinY(world, x, y, z);
    int yMax = block.findMaxY(world, x, y, z);

    double upperDepth = 0;
    double lowerDepth = 0;

    Block blockTop = world.getBlock(x, yMax + 1, z);
    if (blockTop instanceof IChainSingleAttachable) {
        Vec3 topAttach = ((IChainSingleAttachable) blockTop).getChainAttachPoint(world, x, yMax + 1, z, 0);
        if (topAttach != null)
            upperDepth = topAttach.yCoord;
    }

    if (upperDepth == 0) {
        IAttachable attachable = GardenAPI.instance().registries().attachable().getAttachable(blockTop, world.getBlockMetadata(x, y + 1, z));
        if (attachable != null && attachable.isAttachable(world, x, y + 1, z, 0))
            upperDepth = attachable.getAttachDepth(world, x, y + 1, z, 0);
    }

    for (Vec3 point : block.getAttachPoints(world, x, y, z)) {
        float height = yMax - yMin + 2 - (float)point.yCoord + (float)upperDepth;

        double cx = .5f;
        double cz = .5f;
        double dx = cx - point.xCoord;
        double dz = cz - point.zCoord;
        double yt = y + 1;
        double yb = y;

        double localYMin = yMin + point.yCoord - 1;

        if (y == yMin)
            yb = y - 1 + point.yCoord;
        if (y == yMax)
            yt = y + 1 + upperDepth;

        double lerpB = 1 - ((yb - localYMin) / height);
        double lerpT = 1 - ((yt - localYMin) / height);

        drawBetween(renderer, icon, x + dx * lerpB + cx, yb, z + dz * lerpB + cz, x + dx * lerpT + cx, yt, z + dz * lerpT + cz);
    }


    /*double lerpB = ((y - yMin) / height) * .5f;
    double lerpT = ((y + 1 - yMin) / height) * .5f;

    drawBetween(renderer, icon, .005 + x + lerpB, y, z + lerpB, x + lerpT, y + 1, z + lerpT);
    drawBetween(renderer, icon, .005 + x + 1 - lerpB, y, z + lerpB, x + 1 - lerpT, y + 1, z + lerpT);
    drawBetween(renderer, icon, .005 + x + lerpB, y, z + 1 - lerpB, x + lerpT, y + 1, z + 1 - lerpT);
    drawBetween(renderer, icon, .005 + x + 1 - lerpB, y, z + 1 - lerpB, x + 1 - lerpT, y + 1, z + 1 - lerpT);*/

    gardenProxyRenderer.renderWorldBlock(world, x, y, z, ModBlocks.gardenProxy, ModBlocks.gardenProxy.getRenderType(), renderer);

    return true;
}
 
Example 10
Source File: FenceRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockFence block, int modelId, RenderBlocks renderer) {
    int meta = world.getBlockMetadata(x, y, z);

    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

    boxRenderer.setUnit(0);
    boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
    boxRenderer.setIcon(block.getIcon(meta));
    boxRenderer.flipOpposite = false;

    int connectFlags = block.calcConnectionFlags(world, x, y, z);

    boolean connectYNeg = (connectFlags & 1) != 0;
    boolean connectYPos = (connectFlags & 2) != 0;
    boolean connectZNeg = (connectFlags & 4) != 0;
    boolean connectZPos = (connectFlags & 8) != 0;
    boolean connectXNeg = (connectFlags & 16) != 0;
    boolean connectXPos = (connectFlags & 32) != 0;

    boxRenderer.renderSolidBox(world, block, x, y, z, U7, 0, U7, U9, 1, U9);

    if (block.getPostInterval(meta) == 8) {
        if (connectZNeg)
            boxRenderer.renderSolidBox(world, block, x, y, z, U7, 0, 0, U9, 1, U1);
        if (connectZPos)
            boxRenderer.renderSolidBox(world, block, x, y, z, U7, 0, U15, U9, 1, 1);
        if (connectXNeg)
            boxRenderer.renderSolidBox(world, block, x, y, z, 0, 0, U7, U1, 1, U9);
        if (connectXPos)
            boxRenderer.renderSolidBox(world, block, x, y, z, U15, 0, U7, 1, 1, U9);
    }

    boxRenderer.flipOpposite = true;

    boolean fenceBelow = block.isFenceBelow(world, x, y, z);
    boolean abNN = connectYNeg && !fenceBelow && !connectYPos;
    boolean abYY = connectYNeg && fenceBelow && connectYPos;

    if (abNN)
        boxRenderer.setIcon(block.getIconTB(meta));

    float yN = 0;
    float yP = 1;

    if (!(abNN || abYY)) {
        if (connectYPos)
            yN = U8;
        else if (connectYNeg)
            yP = U8;
    }

    if (connectZNeg)
        boxRenderer.renderSolidBox(world, block, x, y, z, U8, yN, 0, U8, yP, U8);
    if (connectZPos)
        boxRenderer.renderSolidBox(world, block, x, y, z, U8, yN, U8, U8, yP, 1);
    if (connectXNeg)
        boxRenderer.renderSolidBox(world, block, x, y, z, 0, yN, U8, U8, yP, U8);
    if (connectXPos)
        boxRenderer.renderSolidBox(world, block, x, y, z, U8, yN, U8, 1, yP, U8);

    if (!(abNN || abYY)) {
        if (connectYPos) {
            yN = 0;
            yP = U8;
        }
        else if (connectYNeg) {
            yN = U8;
            yP = 1;
        }

        boxRenderer.setIcon(block.getIconTB(meta));

        if (connectZNeg)
            boxRenderer.renderSolidBox(world, block, x, y, z, U8, yN, 0, U8, yP, U8);
        if (connectZPos)
            boxRenderer.renderSolidBox(world, block, x, y, z, U8, yN, U8, U8, yP, 1);
        if (connectXNeg)
            boxRenderer.renderSolidBox(world, block, x, y, z, 0, yN, U8, U8, yP, U8);
        if (connectXPos)
            boxRenderer.renderSolidBox(world, block, x, y, z, U8, yN, U8, 1, yP, U8);
    }

    return true;
}
 
Example 11
Source File: RenderHelperAO.java    From GardenCollection with MIT License 4 votes vote down vote up
public void setupYPosAOPartial (IBlockAccess blockAccess, Block block, int x, int y, int z, float r, float g, float b) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(983055);

    if (state.renderMaxY >= 1.0D)
        ++y;

    aoBrightnessXYNP = block.getMixedBrightnessForBlock(blockAccess, x - 1, y, z);
    aoBrightnessXYPP = block.getMixedBrightnessForBlock(blockAccess, x + 1, y, z);
    aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, x, y, z - 1);
    aoBrightnessYZPP = block.getMixedBrightnessForBlock(blockAccess, x, y, z + 1);
    aoBrightnessXYZNPN = aoBrightnessXYNP;
    aoBrightnessXYZPPN = aoBrightnessXYPP;
    aoBrightnessXYZNPP = aoBrightnessXYNP;
    aoBrightnessXYZPPP = aoBrightnessXYPP;

    aoLightValueScratchXYNP = blockAccess.getBlock(x - 1, y, z).getAmbientOcclusionLightValue();
    aoLightValueScratchXYPP = blockAccess.getBlock(x + 1, y, z).getAmbientOcclusionLightValue();
    aoLightValueScratchYZPN = blockAccess.getBlock(x, y, z - 1).getAmbientOcclusionLightValue();
    aoLightValueScratchYZPP = blockAccess.getBlock(x, y, z + 1).getAmbientOcclusionLightValue();
    aoLightValueScratchXYZNPN = aoLightValueScratchXYNP;
    aoLightValueScratchXYZPPN = aoLightValueScratchXYPP;
    aoLightValueScratchXYZNPP = aoLightValueScratchXYNP;
    aoLightValueScratchXYZPPP = aoLightValueScratchXYPP;

    boolean blocksGrassXYPP = blockAccess.getBlock(x + 1, y + 1, z).getCanBlockGrass();
    boolean blocksGrassXYNP = blockAccess.getBlock(x - 1, y + 1, z).getCanBlockGrass();
    boolean blocksGrassYZPP = blockAccess.getBlock(x, y + 1, z + 1).getCanBlockGrass();
    boolean blocksGrassYZPN = blockAccess.getBlock(x, y + 1, z - 1).getCanBlockGrass();

    if (blocksGrassYZPN || blocksGrassXYNP) {
        aoLightValueScratchXYZNPN = blockAccess.getBlock(x - 1, y, z - 1).getAmbientOcclusionLightValue();
        aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, x - 1, y, z - 1);
    }

    if (blocksGrassYZPN || blocksGrassXYPP) {
        aoLightValueScratchXYZPPN = blockAccess.getBlock(x + 1, y, z - 1).getAmbientOcclusionLightValue();
        aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, x + 1, y, z - 1);
    }

    if (blocksGrassYZPP || blocksGrassXYNP) {
        aoLightValueScratchXYZNPP = blockAccess.getBlock(x - 1, y, z + 1).getAmbientOcclusionLightValue();
        aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, x - 1, y, z + 1);
    }

    if (blocksGrassYZPP || blocksGrassXYPP) {
        aoLightValueScratchXYZPPP = blockAccess.getBlock(x + 1, y, z + 1).getAmbientOcclusionLightValue();
        aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, x + 1, y, z + 1);
    }

    if (state.renderMaxY >= 1.0D)
        --y;

    int blockBrightness = block.getMixedBrightnessForBlock(blockAccess, x, y, z);
    if (state.renderMaxY >= 1.0D || !blockAccess.getBlock(x, y + 1, z).isOpaqueCube())
        blockBrightness = block.getMixedBrightnessForBlock(blockAccess, x, y + 1, z);

    float aoOpposingBlock = blockAccess.getBlock(x, y + 1, z).getAmbientOcclusionLightValue();
    float aoXYZNPN = (aoLightValueScratchXYZNPP + aoLightValueScratchXYNP + aoLightValueScratchYZPP + aoOpposingBlock) / 4.0F;  // TR
    float aoXYZNPP = (aoLightValueScratchYZPP + aoOpposingBlock + aoLightValueScratchXYZPPP + aoLightValueScratchXYPP) / 4.0F;  // TL
    float aoXYZPPP = (aoOpposingBlock + aoLightValueScratchYZPN + aoLightValueScratchXYPP + aoLightValueScratchXYZPPN) / 4.0F;  // BL
    float aoXYZPPN = (aoLightValueScratchXYNP + aoLightValueScratchXYZNPN + aoOpposingBlock + aoLightValueScratchYZPN) / 4.0F;  // BR

    float aoTL = (float)((double)aoXYZPPP * state.renderMaxX * (1.0D - state.renderMaxZ) + (double)aoXYZNPP * state.renderMaxX * state.renderMaxZ + (double)aoXYZNPN * (1.0D - state.renderMaxX) * state.renderMaxZ + (double)aoXYZPPN * (1.0D - state.renderMaxX) * (1.0D - state.renderMaxZ));
    float aoBL = (float)((double)aoXYZPPP * state.renderMaxX * (1.0D - state.renderMinZ) + (double)aoXYZNPP * state.renderMaxX * state.renderMinZ + (double)aoXYZNPN * (1.0D - state.renderMaxX) * state.renderMinZ + (double)aoXYZPPN * (1.0D - state.renderMaxX) * (1.0D - state.renderMinZ));
    float aoBR = (float)((double)aoXYZPPP * state.renderMinX * (1.0D - state.renderMinZ) + (double)aoXYZNPP * state.renderMinX * state.renderMinZ + (double)aoXYZNPN * (1.0D - state.renderMinX) * state.renderMinZ + (double)aoXYZPPN * (1.0D - state.renderMinX) * (1.0D - state.renderMinZ));
    float aoTR = (float)((double)aoXYZPPP * state.renderMinX * (1.0D - state.renderMaxZ) + (double)aoXYZNPP * state.renderMinX * state.renderMaxZ + (double)aoXYZNPN * (1.0D - state.renderMinX) * state.renderMaxZ + (double)aoXYZPPN * (1.0D - state.renderMinX) * (1.0D - state.renderMaxZ));

    int brXYZPPN = getAOBrightness(aoBrightnessXYNP, aoBrightnessXYZNPP, aoBrightnessYZPP, blockBrightness);
    int brXYZNPN = getAOBrightness(aoBrightnessYZPP, aoBrightnessXYPP, aoBrightnessXYZPPP, blockBrightness);
    int brXYZNPP = getAOBrightness(aoBrightnessYZPN, aoBrightnessXYZPPN, aoBrightnessXYPP, blockBrightness);
    int brXYZPPP = getAOBrightness(aoBrightnessXYZNPN, aoBrightnessXYNP, aoBrightnessYZPN, blockBrightness);

    state.brightnessTopLeft = mixAOBrightness(brXYZPPP, brXYZPPN, brXYZNPN, brXYZNPP, state.renderMaxZ, state.renderMaxX);
    state.brightnessBottomLeft = mixAOBrightness(brXYZPPP, brXYZPPN, brXYZNPN, brXYZNPP, state.renderMinZ, state.renderMaxX);
    state.brightnessBottomRight = mixAOBrightness(brXYZPPP, brXYZPPN, brXYZNPN, brXYZNPP, state.renderMinZ, state.renderMinX);
    state.brightnessTopRight = mixAOBrightness(brXYZPPP, brXYZPPN, brXYZNPN, brXYZNPP, state.renderMaxZ, state.renderMinX);

    state.setColor(r * state.colorMultYPos, g * state.colorMultYPos, b * state.colorMultYPos);
    state.scaleColor(state.colorTopLeft, aoTL);
    state.scaleColor(state.colorBottomLeft, aoBL);
    state.scaleColor(state.colorBottomRight, aoBR);
    state.scaleColor(state.colorTopRight, aoTR);
}
 
Example 12
Source File: RenderHelperAO.java    From GardenCollection with MIT License 4 votes vote down vote up
public void setupYNegAOPartial (IBlockAccess blockAccess, Block block, int x, int y, int z, float r, float g, float b) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(983055);

    int yGrass = (state.renderMinY <= 0) ? y - 1 : y;

    boolean blocksGrassXYPN = !blockAccess.getBlock(x + 1, yGrass, z).getCanBlockGrass();
    boolean blocksGrassXYNN = !blockAccess.getBlock(x - 1, yGrass, z).getCanBlockGrass();
    boolean blocksGrassYZNP = !blockAccess.getBlock(x, yGrass, z + 1).getCanBlockGrass();
    boolean blocksGrassYZNN = !blockAccess.getBlock(x, yGrass, z - 1).getCanBlockGrass();

    if (state.renderMinY > 0)
        setupAOBrightnessYNeg(blockAccess, block, x, y, z, blocksGrassXYPN, blocksGrassXYNN, blocksGrassYZNP, blocksGrassYZNN);

    setupAOBrightnessYPos(blockAccess, block, x, y - 1, z, blocksGrassXYPN, blocksGrassXYNN, blocksGrassYZNP, blocksGrassYZNN);

    float yClamp = MathHelper.clamp_float((float) state.renderMinY, 0, 1);
    mixAOBrightnessLightValueY(yClamp, 1 - yClamp);

    int blockBrightness = block.getMixedBrightnessForBlock(blockAccess, x, y, z);
    if (state.renderMinY <= 0.0D || !blockAccess.getBlock(x, y - 1, z).isOpaqueCube())
        blockBrightness = block.getMixedBrightnessForBlock(blockAccess, x, y - 1, z);

    float aoOpposingBlock = blockAccess.getBlock(x, y - 1, z).getAmbientOcclusionLightValue();
    float aoXYZNNP = (aoLightValueScratchXYNI + aoLightValueScratchXYZNIP + aoOpposingBlock + aoLightValueScratchYZIP) / 4.0F;
    float aoXYZPNP = (aoOpposingBlock + aoLightValueScratchYZIP + aoLightValueScratchXYPI + aoLightValueScratchXYZPIP) / 4.0F;
    float aoXYZPNN = (aoLightValueScratchYZIN + aoOpposingBlock + aoLightValueScratchXYZPIN + aoLightValueScratchXYPI) / 4.0F;
    float aoXYZNNN = (aoLightValueScratchXYZNIN + aoLightValueScratchXYNI + aoLightValueScratchYZIN + aoOpposingBlock) / 4.0F;

    float aoTR = (float)((double)aoXYZNNP * state.renderMinX * (1.0D - state.renderMaxZ) + (double)aoXYZPNP * state.renderMinX * state.renderMaxZ + (double)aoXYZPNN * (1.0D - state.renderMinX) * state.renderMaxZ + (double)aoXYZNNN * (1.0D - state.renderMinX) * (1.0D - state.renderMaxZ));
    float aoTL = (float)((double)aoXYZNNP * state.renderMinX * (1.0D - state.renderMinZ) + (double)aoXYZPNP * state.renderMinX * state.renderMinZ + (double)aoXYZPNN * (1.0D - state.renderMinX) * state.renderMinZ + (double)aoXYZNNN * (1.0D - state.renderMinX) * (1.0D - state.renderMinZ));
    float aoBL = (float)((double)aoXYZNNP * state.renderMaxX * (1.0D - state.renderMinZ) + (double)aoXYZPNP * state.renderMaxX * state.renderMinZ + (double)aoXYZPNN * (1.0D - state.renderMaxX) * state.renderMinZ + (double)aoXYZNNN * (1.0D - state.renderMaxX) * (1.0D - state.renderMinZ));
    float aoBR = (float)((double)aoXYZNNP * state.renderMaxX * (1.0D - state.renderMaxZ) + (double)aoXYZPNP * state.renderMaxX * state.renderMaxZ + (double)aoXYZPNN * (1.0D - state.renderMaxX) * state.renderMaxZ + (double)aoXYZNNN * (1.0D - state.renderMaxX) * (1.0D - state.renderMaxZ));

    int brXYZNNP = getAOBrightness(aoBrightnessXYNI, aoBrightnessXYZNIP, aoBrightnessYZIP, blockBrightness);
    int brXYZPNP = getAOBrightness(aoBrightnessYZIP, aoBrightnessXYPI, aoBrightnessXYZPIP, blockBrightness);
    int brXYZPNN = getAOBrightness(aoBrightnessYZIN, aoBrightnessXYZPIN, aoBrightnessXYPI, blockBrightness);
    int brXYZNNN = getAOBrightness(aoBrightnessXYZNIN, aoBrightnessXYNI, aoBrightnessYZIN, blockBrightness);

    state.brightnessTopRight = mixAOBrightness(brXYZNNP, brXYZNNN, brXYZPNN, brXYZPNP, state.renderMaxX * (1.0D - state.renderMaxZ), (1.0D - state.renderMaxX) * (1.0D - state.renderMaxZ), (1.0D - state.renderMaxX) * state.renderMaxZ, state.renderMaxX * state.renderMaxZ);
    state.brightnessTopLeft = mixAOBrightness(brXYZNNP, brXYZNNN, brXYZPNN, brXYZPNP, state.renderMaxX * (1.0D - state.renderMinZ), (1.0D - state.renderMaxX) * (1.0D - state.renderMinZ), (1.0D - state.renderMaxX) * state.renderMinZ, state.renderMaxX * state.renderMinZ);
    state.brightnessBottomLeft = mixAOBrightness(brXYZNNP, brXYZNNN, brXYZPNN, brXYZPNP, state.renderMinX * (1.0D - state.renderMinZ), (1.0D - state.renderMinX) * (1.0D - state.renderMinZ), (1.0D - state.renderMinX) * state.renderMinZ, state.renderMinX * state.renderMinZ);
    state.brightnessBottomRight = mixAOBrightness(brXYZNNP, brXYZNNN, brXYZPNN, brXYZPNP, state.renderMinX * (1.0D - state.renderMaxZ), (1.0D - state.renderMinX) * (1.0D - state.renderMaxZ), (1.0D - state.renderMinX) * state.renderMaxZ, state.renderMinX * state.renderMaxZ);

    state.setColor(r * state.colorMultYNeg, g * state.colorMultYNeg, b * state.colorMultYNeg);
    state.scaleColor(state.colorTopLeft, aoTL);
    state.scaleColor(state.colorBottomLeft, aoBL);
    state.scaleColor(state.colorBottomRight, aoBR);
    state.scaleColor(state.colorTopRight, aoTR);
}
 
Example 13
Source File: SmallFireRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockSmallFire block, int modelId, RenderBlocks renderer) {
    Tessellator tessellator = Tessellator.instance;
    IIcon icon0 = block.getFireIcon(0);
    IIcon icon1 = block.getFireIcon(1);
    IIcon icon2 = icon0;

    if (renderer.hasOverrideBlockTexture())
        icon2 = renderer.overrideBlockTexture;

    tessellator.setColorOpaque_F(1, 1, 1);
    tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

    double uMin = icon2.getMinU();
    double vMin = icon2.getMinV();
    double uMax = icon2.getMaxU();
    double vMax = icon2.getMaxV();

    double y0 = y - .0625;
    double y1 = y + 1;

    double x0 = x + .5 + .2;
    double x1 = x + .5 - .2;
    double x2 = x + .5 - .3;
    double x3 = x + .5 + .3;
    double z0 = z + .5 + .2;
    double z1 = z + .5 - .2;
    double z2 = z + .5 - .3;
    double z3 = z + .5 + .3;

    tessellator.addVertexWithUV(x2, y1, z + 1 - .0625f, uMax, vMin);
    tessellator.addVertexWithUV(x0, y0, z + 1 - .0625f, uMax, vMax);
    tessellator.addVertexWithUV(x0, y0, z + 0 + .0625f, uMin, vMax);
    tessellator.addVertexWithUV(x2, y1, z + 0 + .0625f, uMin, vMin);

    tessellator.addVertexWithUV(x3, y1, z + 0 + .0625f, uMax, vMin);
    tessellator.addVertexWithUV(x1, y0, z + 0 + .0625f, uMax, vMax);
    tessellator.addVertexWithUV(x1, y0, z + 1 - .0625f, uMin, vMax);
    tessellator.addVertexWithUV(x3, y1, z + 1 - .0625f, uMin, vMin);

    uMin = icon1.getMinU();
    vMin = icon1.getMinV();
    uMax = icon1.getMaxU();
    vMax = icon1.getMaxV();

    tessellator.addVertexWithUV(x + 1 - .0625f, y1, z3, uMax, vMin);
    tessellator.addVertexWithUV(x + 1 - .0625f, y0, z1, uMax, vMax);
    tessellator.addVertexWithUV(x + 0 + .0625f, y0, z1, uMin, vMax);
    tessellator.addVertexWithUV(x + 0 + .0625f, y1, z3, uMin, vMin);

    tessellator.addVertexWithUV(x + 0 + .0625f, y1, z2, uMax, vMin);
    tessellator.addVertexWithUV(x + 0 + .0625f, y0, z0, uMax, vMax);
    tessellator.addVertexWithUV(x + 1 - .0625f, y0, z0, uMin, vMax);
    tessellator.addVertexWithUV(x + 1 - .0625f, y1, z2, uMin, vMin);

    x0 = x + .5 - .5 + .125f;
    x1 = x + .5 + .5 - .125f;
    x2 = x + .5 - .4 + .125f;
    x3 = x + .5 + .4 - .125f;
    z0 = z + .5 - .5 + .125f;
    z1 = z + .5 + .5 - .125f;
    z2 = z + .5 - .4 + .125f;
    z3 = z + .5 + .4 - .125f;

    tessellator.addVertexWithUV(x2, y1, z + 0, uMax, vMin);
    tessellator.addVertexWithUV(x0, y0, z + 0, uMax, vMax);
    tessellator.addVertexWithUV(x0, y0, z + 1, uMin, vMax);
    tessellator.addVertexWithUV(x2, y1, z + 1, uMin, vMin);

    tessellator.addVertexWithUV(x3, y1, z + 1, uMax, vMin);
    tessellator.addVertexWithUV(x1, y0, z + 1, uMax, vMax);
    tessellator.addVertexWithUV(x1, y0, z + 0, uMin, vMax);
    tessellator.addVertexWithUV(x3, y1, z + 0, uMin, vMin);

    uMin = icon0.getMinU();
    vMin = icon0.getMinV();
    uMax = icon0.getMaxU();
    vMax = icon0.getMaxV();

    tessellator.addVertexWithUV(x + 0, y1, z3, uMax, vMin);
    tessellator.addVertexWithUV(x + 0, y0, z1, uMax, vMax);
    tessellator.addVertexWithUV(x + 1, y0, z1, uMin, vMax);
    tessellator.addVertexWithUV(x + 1, y1, z3, uMin, vMin);

    tessellator.addVertexWithUV(x + 1, y1, z2, uMax, vMin);
    tessellator.addVertexWithUV(x + 1, y0, z0, uMax, vMax);
    tessellator.addVertexWithUV(x + 0, y0, z0, uMin, vMax);
    tessellator.addVertexWithUV(x + 0, y1, z2, uMin, vMin);

    return true;
}
 
Example 14
Source File: RenderHelper.java    From GardenCollection with MIT License 4 votes vote down vote up
public void renderCrossedSquares (Block block, int meta, IIcon icon) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(FULL_BRIGHTNESS);

    calculateBaseColor(colorScratch, block.getRenderColor(meta));
    setTessellatorColor(tessellator, colorScratch);

    boolean lighting = GL11.glIsEnabled(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_LIGHTING);

    tessellator.startDrawingQuads();

    drawCrossedSquares(icon, 0, 0, 0, 1.0F);

    tessellator.draw();

    if (lighting)
        GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example 15
Source File: RotorSpecialRenderer.java    From BigReactors with MIT License 4 votes vote down vote up
int generateRotor(RotorInfo rotorInfo) {
	int list = GLAllocation.generateDisplayLists(1);
	GL11.glNewList(list,  GL11.GL_COMPILE);

	ForgeDirection rotorDir = rotorInfo.rotorDirection;
	int rotorLen = rotorInfo.rotorLength;
	CoordTriplet currentRotorCoord = new CoordTriplet(0,0,0);

	Tessellator tessellator = Tessellator.instance;
	if(rotorDir.offsetX != 0) {
		tessellator.setTranslation(0, -0.5, -0.5);
	}
	else if(rotorDir.offsetY != 0) {
		tessellator.setTranslation(-0.5, 0, -0.5);
	}
	else {
		tessellator.setTranslation(-0.5, -0.5, 0);
	}

	tessellator.startDrawingQuads();
	tessellator.setBrightness(256);
	tessellator.setColorOpaque(255, 255, 255);
	
	CoordTriplet bladeCoord = new CoordTriplet(0,0,0);
	int rotorIdx = 0;
	boolean[] hasBlades = new boolean[4];
	ForgeDirection[] bladeDirs = StaticUtils.neighborsBySide[rotorInfo.rotorDirection.ordinal()];

	while(rotorIdx < rotorInfo.rotorLength) {
		
		for(int i = 0; i < hasBlades.length; i++) {
			hasBlades[i] = rotorInfo.bladeLengths[rotorIdx][i] > 0;
		}

		RotorSimpleRenderer.renderRotorShaft(BigReactors.blockTurbineRotorPart, renderBlocks, BlockTurbineRotorPart.METADATA_SHAFT, rotorDir, hasBlades, currentRotorCoord.x, currentRotorCoord.y, currentRotorCoord.z, false);
		for(int bladeIdx = 0; bladeIdx < bladeDirs.length; bladeIdx++) {
			bladeCoord.copy(currentRotorCoord);
			int bladeLen = 0;
			bladeCoord.translate(bladeDirs[bladeIdx]);
			while(bladeLen < rotorInfo.bladeLengths[rotorIdx][bladeIdx]) {
				RotorSimpleRenderer.renderBlade(renderBlocks, bladeCoord.x, bladeCoord.y, bladeCoord.z, BigReactors.blockTurbineRotorPart, BlockTurbineRotorPart.METADATA_BLADE, rotorInfo.rotorDirection);
				bladeLen++;
				bladeCoord.translate(bladeDirs[bladeIdx]);
			}
		}
		rotorIdx++;
		currentRotorCoord.translate(rotorDir);
	}
	tessellator.setTranslation(0, 0, 0);
	tessellator.draw();
	
	GL11.glEndList();
	return list;
}
 
Example 16
Source File: CompostBinRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockCompostBin block, int modelId, RenderBlocks renderer) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

    boxRenderer.setUnit(.0625);
    boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
    boxRenderer.setCutIcon(block.getInnerIcon());
    for (int side = 0; side < 6; side++) {
        boxRenderer.setExteriorIcon(block.getIcon(world, x, y, z, side), side);
        boxRenderer.setInteriorIcon(block.getIcon(world, x, y, z, side), side);
    }

    boxRenderer.renderBox(world, block, x, y, z, 0, 0, 0, 1, 1, 1, 0, ModularBoxRenderer.CUT_YPOS);

    boxRenderer.setUnit(0);
    boxRenderer.setInteriorIcon(block.getIcon(world, x, y, z, 1));

    boxRenderer.renderInterior(world, block, x, y, z, .125, .625, .9375, .875, .75, 1, 0, ModularBoxRenderer.CUT_ZNEG | ModularBoxRenderer.CUT_ZPOS);
    boxRenderer.renderInterior(world, block, x, y, z, .125, .25, .9375, .875, .375, 1, 0, ModularBoxRenderer.CUT_ZNEG | ModularBoxRenderer.CUT_ZPOS);

    boxRenderer.renderInterior(world, block, x, y, z, .125, .625, 0, .875, .75, .0625, 0, ModularBoxRenderer.CUT_ZNEG | ModularBoxRenderer.CUT_ZPOS);
    boxRenderer.renderInterior(world, block, x, y, z, .125, .25, 0, .875, .375, .0625, 0, ModularBoxRenderer.CUT_ZNEG | ModularBoxRenderer.CUT_ZPOS);

    boxRenderer.renderInterior(world, block, x, y, z, .9375, .625, .125, 1, .75, .875, 0, ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_XPOS);
    boxRenderer.renderInterior(world, block, x, y, z, .9375, .25, .125, 1, .375, .875, 0, ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_XPOS);

    boxRenderer.renderInterior(world, block, x, y, z, 0, .625, .125, .0625, .75, .875, 0, ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_XPOS);
    boxRenderer.renderInterior(world, block, x, y, z, 0, .25, .125, .0625, .375, .875, 0, ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_XPOS);


    TileEntityCompostBin te = (TileEntityCompostBin) world.getTileEntity(x, y, z);
    if (te != null) {
        if (te.hasInputItems()) {
            boxRenderer.setExteriorIcon(Blocks.dirt.getIcon(1, 2));
            boxRenderer.renderSolidBox(world, block, x, y, z, .0625, .0625, .0625, 1 - .0625, 1 - .0625, 1 - .0625);
        }
        else if (te.hasOutputItems()) {
            boxRenderer.setExteriorIcon(ModBlocks.gardenSoil.getIcon(1, 0));
            boxRenderer.renderSolidBox(world, block, x, y, z, .0625, .0625, .0625, 1 - .0625, 1 - .0625, 1 - .0625);
        }
    }

    return true;
}
 
Example 17
Source File: DecorativePotRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockDecorativePot block, int modelId, RenderBlocks renderer) {
    int data = world.getBlockMetadata(x, y, z);

    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

    RenderHelper.calculateBaseColor(baseColor, block.colorMultiplier(world, x, y, z));

    float unit = .0625f;

    for (int i = 0; i < 6; i++)
        boxRenderer.setIcon(renderer.getBlockIconFromSideAndMetadata(block, i, data), i);

    boxRenderer.setColor(baseColor);
    boxRenderer.renderBox(world, block, x, y, z, 0, 14 * unit, 0, 1, 1, 1, 0, ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_YPOS);
    boxRenderer.setScaledColor(baseColor, .9375f);
    boxRenderer.renderBox(world, block, x, y, z, 1 * unit, 8 * unit, 1 * unit, 15 * unit, 16 * unit, 15 * unit, 0, ModularBoxRenderer.CUT_YPOS);

    boxRenderer.setScaledExteriorColor(baseColor, .875f);
    boxRenderer.renderSolidBox(world, block, x, y, z, 3 * unit, 6 * unit, 3 * unit, 13 * unit, 8 * unit, 13 * unit);
    boxRenderer.setScaledExteriorColor(baseColor, .8125f);
    boxRenderer.renderSolidBox(world, block, x, y, z, 5 * unit, 3 * unit, 5 * unit, 11 * unit, 6 * unit, 11 * unit);
    boxRenderer.setScaledExteriorColor(baseColor, .9375f);
    boxRenderer.setScaledExteriorColor(baseColor, .75f, 1);
    boxRenderer.renderSolidBox(world, block, x, y, z, 2 * unit, 0 * unit, 2 * unit, 14 * unit, 3 * unit, 14 * unit);

    TileEntityDecorativePot te = block.getTileEntity(world, x, y, z);
    ItemStack substrateItem = block.getGardenSubstrate(world, x, y, z, Slot2Profile.SLOT_CENTER);
    if (te != null && substrateItem != null && substrateItem.getItem() instanceof ItemBlock) {
        Block substrate = Block.getBlockFromItem(substrateItem.getItem());
        IIcon substrateIcon = renderer.getBlockIconFromSideAndMetadata(substrate, 1, substrateItem.getItemDamage());

        int color = substrate.colorMultiplier(world, x, y, z);
        if (color == Blocks.grass.colorMultiplier(world, x, y, z))
            color = ColorizerGrass.getGrassColor(te.getBiomeTemperature(), te.getBiomeHumidity());

        RenderHelper.calculateBaseColor(activeSubstrateColor, color);
        RenderHelper.scaleColor(activeSubstrateColor, activeSubstrateColor, .8f);

        RenderHelper.instance.setRenderBounds(.0625f, 0, .0625f, 1f - .0625f, 1f - .0625f, 1f - .0625f);
        RenderHelper.instance.renderFace(RenderHelper.YPOS, world, block, x, y, z, substrateIcon, activeSubstrateColor[0], activeSubstrateColor[1], activeSubstrateColor[2]);
    }

    return true;
}
 
Example 18
Source File: TileEntityRendererMonitorStorageFluid.java    From ExtraCells1 with MIT License 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTickTime)
{
	if (tileentity instanceof TileEntityMonitorStorageFluid)
	{
		Fluid fluid = ((TileEntityMonitorStorageFluid) tileentity).getFluid();
		if (fluid == null || fluid.getIcon() == null)
			return;
		Icon fluidIcon = fluid.getFlowingIcon();

		GL11.glPushMatrix();
		GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

		FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
		ForgeDirection d = ForgeDirection.getOrientation(tileentity.blockMetadata);
		GL11.glTranslated(x + 0.5D, y + 0.5D, z + 0.5D);
		GL11.glTranslated(d.offsetX * 0.76D, d.offsetY * 0.76D, d.offsetZ * 0.76D);
		if (d == ForgeDirection.UP)
		{
			GL11.glScalef(1.0F, -1.0F, 1.0F);
			GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
			GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
		}

		if (d == ForgeDirection.DOWN)
		{
			GL11.glScalef(1.0F, -1.0F, 1.0F);
			GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
			GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
		}

		if (d == ForgeDirection.EAST)
		{
			GL11.glScalef(-1.0F, -1.0F, -1.0F);
			GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
		}

		if (d == ForgeDirection.WEST)
		{
			GL11.glScalef(-1.0F, -1.0F, -1.0F);
			GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
		}

		if (d == ForgeDirection.NORTH)
		{
			GL11.glScalef(-1.0F, -1.0F, -1.0F);
		}

		if (d == ForgeDirection.SOUTH)
		{
			GL11.glScalef(-1.0F, -1.0F, -1.0F);
			GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
		}

		GL11.glTranslatef(0.01F, 0.13F, -0.24F);
		GL11.glScalef(0.0625F * 0.25F, 0.0625F * 0.25F, 0.01612903F);

		long qty = ((TileEntityMonitorStorageFluid) tileentity).getAmount();
		if (qty > 999999999999L)
		{
			qty = 999999999999L;
		}
		String msg = Long.toString(qty) + "mB";
		if (Extracells.shortenedBuckets)
		{
			if (qty > 1000000000L)
				msg = Long.toString(qty / 1000000000L) + "MegaB";
			else if (qty > 1000000L)
				msg = Long.toString(qty / 1000000L) + "KiloB";
			else if (qty > 9999L)
			{
				msg = Long.toString(qty / 1000L) + "B";
			}
		}

		TileEntityMonitorStorageFluid TE = (TileEntityMonitorStorageFluid) tileentity;
		if (TE.isMachineActive())
		{
			GL11.glTranslated(-8.6F, -16.3, -1.2F);
			Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
			Tessellator cake = Tessellator.instance;
			cake.startDrawingQuads();
			cake.setBrightness(255);
			cake.setColorRGBA_F(1.0f, 1.0f, 1.0f, 1.0f);
			cake.addVertexWithUV(0, 16, 0, fluidIcon.getMinU(), fluidIcon.getMaxV());
			cake.addVertexWithUV(16, 16, 0, fluidIcon.getMaxU(), fluidIcon.getMaxV());
			cake.addVertexWithUV(16, 0, 0, fluidIcon.getMaxU(), fluidIcon.getMinV());
			cake.addVertexWithUV(0, 0, 0, fluidIcon.getMinU(), fluidIcon.getMinV());
			cake.draw();

			int width = fr.getStringWidth(msg);
			GL11.glTranslatef(8.25F - 0.5F * width, 24.0F, 0);
			GL11.glScaled(1, 0.5, 1);
			fr.drawString(msg, 0, 0, 0x00FFFF);
		}
		GL11.glPopMatrix();
		GL11.glPopAttrib();
	}
}
 
Example 19
Source File: RenderBlockGauge.java    From archimedes-ships with MIT License 4 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
	Tessellator tessellator = Tessellator.instance;
	int l = world.getBlockMetadata(x, y, z);
	IIcon iicon = renderer.getBlockIconFromSideAndMetadata(block, 0, l);
	int dir = l & 3;
	
	tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
	tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
	double u0 = iicon.getMinU();
	double v0 = iicon.getMinV();
	double u1 = iicon.getMaxU();
	double v1 = iicon.getMaxV();
	double yoffset = 0.0625D;
	double dx = x + 1;
	double dz = z + 1;
	double dy = y + yoffset;
	
	switch (dir)
	{
	case 0:
		tessellator.addVertexWithUV(x, dy, z, u1, v1);
		tessellator.addVertexWithUV(x, dy, dz, u1, v0);
		tessellator.addVertexWithUV(dx, dy, dz, u0, v0);
		tessellator.addVertexWithUV(dx, dy, z, u0, v1);
		break;
	case 1:
		tessellator.addVertexWithUV(x, dy, z, u1, v0);
		tessellator.addVertexWithUV(x, dy, dz, u0, v0);
		tessellator.addVertexWithUV(dx, dy, dz, u0, v1);
		tessellator.addVertexWithUV(dx, dy, z, u1, v1);
		break;
	case 2:
		tessellator.addVertexWithUV(x, dy, z, u0, v0);
		tessellator.addVertexWithUV(x, dy, dz, u0, v1);
		tessellator.addVertexWithUV(dx, dy, dz, u1, v1);
		tessellator.addVertexWithUV(dx, dy, z, u1, v0);
		break;
	case 3:
	default:
		tessellator.addVertexWithUV(x, dy, z, u0, v1);
		tessellator.addVertexWithUV(x, dy, dz, u1, v1);
		tessellator.addVertexWithUV(dx, dy, dz, u1, v0);
		tessellator.addVertexWithUV(dx, dy, z, u0, v0);
	}
	return true;
}
 
Example 20
Source File: RenderHelperTerminalFluid.java    From ExtraCells1 with MIT License 4 votes vote down vote up
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
	Tessellator tessellator = Tessellator.instance;
	block.setBlockBoundsForItemRender();
	GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

	tessellator.startDrawingQuads();
	tessellator.setNormal(0.0F, -1.0F, 0.0F);
	renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata));
	tessellator.draw();
	tessellator.startDrawingQuads();
	tessellator.setNormal(0.0F, 1.0F, 0.0F);
	renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata));
	tessellator.draw();
	tessellator.startDrawingQuads();
	tessellator.setNormal(0.0F, 0.0F, -1.0F);
	tessellator.addTranslation(0.0F, 0.0F, 0.0F);
	renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata));
	tessellator.addTranslation(0.0F, 0.0F, 0.0F);
	tessellator.draw();
	tessellator.startDrawingQuads();
	tessellator.setNormal(0.0F, 0.0F, 1.0F);
	tessellator.addTranslation(0.0F, 0.0F, 0.0F);
	renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata));
	tessellator.addTranslation(0.0F, 0.0F, 0.0F);
	tessellator.draw();
	tessellator.startDrawingQuads();
	tessellator.setNormal(-1.0F, 0.0F, 0.0F);
	tessellator.addTranslation(0.0F, 0.0F, 0.0F);

	tessellator.setBrightness(15 << 20 | 15 << 6);
	tessellator.setColorRGBA_I(0xFFFFFF, 0xFF);
	int[] color =
	{ 0x1B2344, 0x895CA8, 0xDABDEF };
	BlockTerminalFluid terminal = (BlockTerminalFluid) block;
	renderer.renderFaceXNeg(block, 0, 0, 0, terminal.baseLayer);
	for (int i = 0; i < 3; i++)
	{
		tessellator.setColorRGBA_I(color[i], 0xFF);
		renderer.renderFaceXNeg(block, 0, 0, 0, terminal.colorLayers[i]);
	}

	tessellator.addTranslation(0.0F, 0.0F, 0.0F);
	tessellator.draw();
	tessellator.startDrawingQuads();
	tessellator.setNormal(1.0F, 0.0F, 0.0F);
	tessellator.addTranslation(0.0F, 0.0F, 0.0F);
	renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata));
	tessellator.addTranslation(0.0F, 0.0F, 0.0F);
	tessellator.draw();

	GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}