Jump to content

ISimpleBlockRenderingHandler enable Ambient Occlusion and shadows


Recommended Posts

Posted

Hi, i made a custom modeled translucent block (glacia column) and now i need to know how to enable ambient occlusion so that i can make it generate shadows and make it shadowed on the bottom.

 

here is my rendering code

 

RenderGlaciaColumn:

 

package net.minecraft.src;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import org.lwjgl.opengl.GL11;
import net.minecraft.util.ResourceLocation;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.Icon;

public class RenderGlaciaColumn extends RenderBlocks implements ISimpleBlockRenderingHandler
{

public Icon getIcon0;
public Icon getIcon1;
public Icon getIcon2;

    public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
getIcon0 = block.getIcon(0, 0);
getIcon1 = block.getIcon(0, 1);
getIcon2 = block.getIcon(0, 2);

double minU2 = (double)getIcon0.getMinU();
double minV2 = (double)getIcon0.getMinV();
double maxU2 = (double)getIcon0.getMaxU();
double maxV2 = (double)getIcon0.getMaxV();
double minU1 = (double)getIcon1.getMinU();
    double minV1 = (double)getIcon1.getMinV();
    double maxU1 = (double)getIcon1.getMaxU();
    double maxV1 = (double)getIcon1.getMaxV();
double minU3 = (double)getIcon2.getMinU();
    double minV3 = (double)getIcon2.getMinV();
    double maxU3 = (double)getIcon2.getMaxU();
    double maxV3 = (double)getIcon2.getMaxV();
Tessellator tessellator = Tessellator.instance;
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

//portantdown face 1

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    tessellator.addVertexWithUV(1.0, 0.0, 0.0, maxU2, maxV2);
tessellator.addVertexWithUV(0.0, 0.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(0.0, 0.25, 0.0, minU2, minV2);
tessellator.addVertexWithUV(1.0, 0.25, 0.0, minU2, maxV2);
    tessellator.draw();

//portantdown face inverse  1

tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.addVertexWithUV(1.0, 0.25, 1.0, minU2, maxV2);
tessellator.addVertexWithUV(0.0, 0.25, 1.0, minU2, minV2);
tessellator.addVertexWithUV(0.0, 0.0, 1.0, maxU2, minV2);
tessellator.addVertexWithUV(1.0, 0.0, 1.0, maxU2, maxV2);
tessellator.draw();

// portantdown face 2
tessellator.startDrawingQuads();
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(0.0, 0.25, 1.0, minU2, maxV2);
tessellator.addVertexWithUV(0.0, 0.25, 0.0, minU2, minV2);
tessellator.addVertexWithUV(0.0, 0.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(0.0, 0.0, 1.0, maxU2, maxV2);
tessellator.draw();

// portantdown face inverse 2
tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(1.0, 0.0, 1.0, maxU2, maxV2);
tessellator.addVertexWithUV(1.0, 0.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(1.0, 0.25, 0.0, minU2, minV2);
tessellator.addVertexWithUV(1.0, 0.25, 1.0, minU2, maxV2);
tessellator.draw();

// portantup face 1
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.addVertexWithUV(1.0, 0.75, 0.0, minU2, maxV2);
tessellator.addVertexWithUV(0.0, 0.75, 0.0, minU2, minV2);
tessellator.addVertexWithUV(0.0, 1.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(1.0, 1.0, 0.0, maxU2, maxV2);
tessellator.draw();

// portantup face inverse 1
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.addVertexWithUV(1.0, 1.0, 1.0, maxU2, maxV2);
tessellator.addVertexWithUV(0.0, 1.0, 1.0, maxU2, minV2);
tessellator.addVertexWithUV(0.0, 0.75, 1.0, minU2, minV2);
tessellator.addVertexWithUV(1.0, 0.75, 1.0, minU2, maxV2);
tessellator.draw();

// portantup face 2
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(1.0, 0.75, 1.0, minU2, maxV2);
tessellator.addVertexWithUV(1.0, 0.75, 0.0, minU2, minV2);
tessellator.addVertexWithUV(1.0, 1.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(1.0, 1.0, 1.0, maxU2, maxV2);
tessellator.draw();

// portantup face inverse 2
tessellator.startDrawingQuads();
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(0.0, 1.0, 1.0, maxU2, maxV2);
tessellator.addVertexWithUV(0.0, 1.0, 0.0, maxU2, minV2);
tessellator.addVertexWithUV(0.0, 0.75, 0.0, minU2, minV2);
tessellator.addVertexWithUV(0.0, 0.75, 1.0, minU2, maxV2);
tessellator.draw();

// portantup base up
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV(0.0, 1.0, 0.0, maxU1, maxV1);
tessellator.addVertexWithUV(0.0, 1.0, 1.0, maxU1, minV1);
tessellator.addVertexWithUV(1.0, 1.0, 1.0, minU1, minV1);
tessellator.addVertexWithUV(1.0, 1.0, 0.0, minU1, maxV1);
tessellator.draw();

// portantup base down
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.addVertexWithUV(1.0, 0.75, 0.0, minU1, maxV1);
tessellator.addVertexWithUV(1.0, 0.75, 1.0, minU1, minV1);
tessellator.addVertexWithUV(0.0, 0.75, 1.0, maxU1, minV1);
tessellator.addVertexWithUV(0.0, 0.75, 0.0, maxU1, maxV1);
tessellator.draw();

// portantdown base up
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV(0.0, 0.25, 0.0, maxU1, maxV1);
tessellator.addVertexWithUV(0.0, 0.25, 1.0, maxU1, minV1);
tessellator.addVertexWithUV(1.0, 0.25, 1.0, minU1, minV1);
tessellator.addVertexWithUV(1.0, 0.25, 0.0, minU1, maxV1);
tessellator.draw();

// portantdown base down
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.addVertexWithUV(1.0, 0.0, 0.0, minU1, maxV1);
tessellator.addVertexWithUV(1.0, 0.0, 1.0, minU1, minV1);
tessellator.addVertexWithUV(0.0, 0.0, 1.0, maxU1, minV1);
tessellator.addVertexWithUV(0.0, 0.0, 0.0, maxU1, maxV1);
tessellator.draw();

// pillar 1
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.addVertexWithUV(0.25, 0.99, 0.25, minU3, minV3);
tessellator.addVertexWithUV(0.75, 0.99, 0.25, minU3, maxV3);
tessellator.addVertexWithUV(0.75, 0.0, 0.25, maxU3, maxV3);
tessellator.addVertexWithUV(0.25, 0.0, 0.25, maxU3, minV3);
tessellator.draw();

// pillar inverse 1
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.addVertexWithUV(0.75, 0.99, 0.75, minU3, minV3);
tessellator.addVertexWithUV(0.25, 0.99, 0.75, minU3, maxV3);
tessellator.addVertexWithUV(0.25, 0.0, 0.75, maxU3, maxV3);
tessellator.addVertexWithUV(0.75, 0.0, 0.75, maxU3, minV3);
tessellator.draw();

// pillar 2
tessellator.startDrawingQuads();
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(0.25, 0.99, 0.75, minU3, minV3);
tessellator.addVertexWithUV(0.25, 0.99, 0.25, minU3, maxV3);
tessellator.addVertexWithUV(0.25, 0.0, 0.25, maxU3, maxV3);
tessellator.addVertexWithUV(0.25, 0.0, 0.75, maxU3, minV3);
tessellator.draw();

// pillar inverse 2
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.addVertexWithUV(0.75, 0.99, 0.25, minU3, minV3);
tessellator.addVertexWithUV(0.75, 0.99, 0.75, minU3, maxV3);
tessellator.addVertexWithUV(0.75, 0.0, 0.75, maxU3, maxV3);
tessellator.addVertexWithUV(0.75, 0.0, 0.25, maxU3, minV3);
tessellator.draw();

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

@Override
    public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
    {
	Tessellator tessellator = Tessellator.instance;
	int lightValue = block.getMixedBrightnessForBlock(world, x, y, z);
	tessellator.setBrightness(lightValue);
	tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);

	getIcon0 = block.getIcon(0, 0);
	getIcon1 = block.getIcon(0, 1);
	getIcon2 = block.getIcon(0, 2);

	if (world.getBlockMetadata(x, y, z) == 3)
	{
	renderColumnFull(tessellator, (double)x, (double)y, (double) z);
	}
	else if (world.getBlockMetadata(x, y, z) == 2)
	{
	renderColumnDown(tessellator, (double)x, (double)y, (double) z, block, world);
	} 
	else if (world.getBlockMetadata(x, y, z) == 1)
	{
	renderColumnUp(tessellator, (double)x, (double)y, (double) z, block, world);
	}
	else
	{
	renderColumnCenter(tessellator, (double)x, (double)y, (double) z, block, world);
	} 
	return true;


	//aModel.ColumnDown.showModel = false;
	//aModel.ColumnUp.showModel = false;
	//aModel.ColumnFull.showModel = false;
	//aModel.PortantUp.showModel = true;
	//aModel.PortantDown.showModel = true;
	//aModel.ColumnCenter.showModel = true;

	//GL11.glBindTexture(GL11.GL_TEXTURE_2D, 2);
	//GL11.glPushMatrix();
	//GL11.glTranslatef((float)x + 0.5F, (float)y - 0.50F, (float)z + 0.5F);
	//GL11.glRotatef(0, 0F, 0F, 0F);
	//GL11.glPushMatrix();
	//aModel.renderModel(0.0625F);
	//GL11.glPopMatrix();
	//GL11.glPopMatrix();

	//tessellator.startDrawingQuads();
	//tessellator.setNormal(0.0F, -1.0F, 0.0F);
	//tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, minU1, maxV1);
	//tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, minU1, minV1);
	//tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU1, minV1);
	//tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU1, maxV1);
}

    public boolean shouldRender3DInInventory(){ return true; }

@Override
public int getRenderId()
{
	return mod_Glacia.rendercolumnID;
}

private void renderColumnFull(Tessellator tessellator, double x, double y, double z) {

    double minU2 = (double)getIcon0.getMinU();
    double minV2 = (double)getIcon0.getMinV();
    double maxU2 = (double)getIcon0.getMaxU();
    double maxV2 = (double)getIcon0.getMaxV();
    double minU1 = (double)getIcon1.getMinU();
    double minV1 = (double)getIcon1.getMinV();
    double maxU1 = (double)getIcon1.getMaxU();
    double maxV1 = (double)getIcon1.getMaxV();
double minU3 = (double)getIcon2.getMinU();
    double minV3 = (double)getIcon2.getMinV();
    double maxU3 = (double)getIcon2.getMaxU();
    double maxV3 = (double)getIcon2.getMaxV();

// portantdown face 1
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face inverse 1
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face 2
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face inverse 2
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face 2
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face inverse 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup base up
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU1, maxV1);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, minU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup base down
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.setColorOpaque_F(0.5F, 0.5F, 0.5F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU1, maxV1);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, maxU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown base up
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, maxU1, maxV1);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown base down
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.setColorOpaque_F(0.5F, 0.5F, 0.5F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, minU1, maxV1);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 2
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();
  }
  
  private void renderColumnUp(Tessellator tessellator, double x, double y, double z, Block block, IBlockAccess world) {

    double minU2 = (double)getIcon0.getMinU();
    double minV2 = (double)getIcon0.getMinV();
    double maxU2 = (double)getIcon0.getMaxU();
    double maxV2 = (double)getIcon0.getMaxV();
    double minU1 = (double)getIcon1.getMinU();
    double minV1 = (double)getIcon1.getMinV();
    double maxU1 = (double)getIcon1.getMaxU();
    double maxV1 = (double)getIcon1.getMaxV();
double minU3 = (double)getIcon2.getMinU();
    double minV3 = (double)getIcon2.getMinV();
    double maxU3 = (double)getIcon2.getMaxU();
    double maxV3 = (double)getIcon2.getMaxV();

int lightValue = block.getMixedBrightnessForBlock(world, (int)x, (int)y, (int)z);

// portantup face 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face 2
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup face inverse 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup base up
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+0.0, maxU1, maxV1);
tessellator.addVertexWithUV(x+0.0, y+1.0, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+1.0, z+0.0, minU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// portantup base down
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.setColorOpaque_F(0.5F, 0.5F, 0.5F);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+0.0, minU1, maxV1);
tessellator.addVertexWithUV(x+1.0, y+0.75, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.75, z+0.0, maxU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 2
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();
  }
  
  private void renderColumnDown(Tessellator tessellator, double x, double y, double z, Block block, IBlockAccess world) {

    double minU2 = (double)getIcon0.getMinU();
    double minV2 = (double)getIcon0.getMinV();
    double maxU2 = (double)getIcon0.getMaxU();
    double maxV2 = (double)getIcon0.getMaxV();
    double minU1 = (double)getIcon1.getMinU();
    double minV1 = (double)getIcon1.getMinV();
    double maxU1 = (double)getIcon1.getMaxU();
    double maxV1 = (double)getIcon1.getMaxV();
double minU3 = (double)getIcon2.getMinU();
    double minV3 = (double)getIcon2.getMinV();
    double maxU3 = (double)getIcon2.getMaxU();
    double maxV3 = (double)getIcon2.getMaxV();

int lightValue = block.getMixedBrightnessForBlock(world, (int)x, (int)y, (int)z);

// portantdown face 1
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face inverse 1
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face 2
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown face inverse 2
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, maxU2, maxV2);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, maxU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU2, minV2);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU2, maxV2);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown base up
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+0.0, maxU1, maxV1);
tessellator.addVertexWithUV(x+0.0, y+0.25, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+1.0, y+0.25, z+0.0, minU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// portantdown base down
tessellator.setNormal(0.0F, -1.0F, 0.0F);
tessellator.setColorOpaque_F(0.5F, 0.5F, 0.5F);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+0.0, minU1, maxV1);
tessellator.addVertexWithUV(x+1.0, y+0.0, z+1.0, minU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+1.0, maxU1, minV1);
tessellator.addVertexWithUV(x+0.0, y+0.0, z+0.0, maxU1, maxV1);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 2
tessellator.setNormal(1.0F, -1.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();
  }
  
  private void renderColumnCenter(Tessellator tessellator, double x, double y, double z, Block block, IBlockAccess world) {

    double minU2 = (double)getIcon0.getMinU();
    double minV2 = (double)getIcon0.getMinV();
    double maxU2 = (double)getIcon0.getMaxU();
    double maxV2 = (double)getIcon0.getMaxV();
    double minU1 = (double)getIcon1.getMinU();
    double minV1 = (double)getIcon1.getMinV();
    double maxU1 = (double)getIcon1.getMaxU();
    double maxV1 = (double)getIcon1.getMaxV();
double minU3 = (double)getIcon2.getMinU();
    double minV3 = (double)getIcon2.getMinV();
    double maxU3 = (double)getIcon2.getMaxU();
    double maxV3 = (double)getIcon2.getMaxV();

int lightValue = block.getMixedBrightnessForBlock(world, (int)x, (int)y, (int)z);

// pillar 1
tessellator.setNormal(0.0F, 0.0F, 1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 1
tessellator.setNormal(0.0F, 0.0F, -1.0F);
tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar 2
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.75, minU3, minV3);
tessellator.addVertexWithUV(x+0.25, y+1.0, z+0.25, minU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.25, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.25, y+0.0, z+0.75, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();

// pillar inverse 2
tessellator.setNormal(1.0F, 0.0F, 0.0F);
tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.25, minU3, minV3);
tessellator.addVertexWithUV(x+0.75, y+1.0, z+0.75, minU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.75, maxU3, maxV3);
tessellator.addVertexWithUV(x+0.75, y+0.0, z+0.25, maxU3, minV3);
tessellator.draw();
tessellator.startDrawingQuads();
  }
}

 

 

here is a screen:

450y.png

Actually i don't know what to write in this signature soooo.... anyway

Posted

Hi

 

Cute reindeer there... is that in the new update?

 

What you're asking isn't as simple as you might think.

 

There's some background info on Minecraft ambient occlusion here:

http://greyminecraftcoder.blogspot.com.au/2013/08/lighting.html

 

The Ambient occlusion code in vanilla is in

.renderBlockWithAmbientOcclusion() and .renderStandardBlockWithAmbientOcclusion()

and they assume a cube or rectangular prism.  Your block is an unusual shape so the vanilla code won't handle it properly.

 

Disclaimer - if it's different in 1.7, I don't know about that yet.

 

If you see another vanilla block that does the same thing as what you want, perhaps the rendering code for that block might give you clues?

 

-TGG

 

 

 

Posted

Hi

 

Cute reindeer there... is that in the new update?

 

What you're asking isn't as simple as you might think.

 

There's some background info on Minecraft ambient occlusion here:

http://greyminecraftcoder.blogspot.com.au/2013/08/lighting.html

 

The Ambient occlusion code in vanilla is in

.renderBlockWithAmbientOcclusion() and .renderStandardBlockWithAmbientOcclusion()

and they assume a cube or rectangular prism.  Your block is an unusual shape so the vanilla code won't handle it properly.

 

Disclaimer - if it's different in 1.7, I don't know about that yet.

 

If you see another vanilla block that does the same thing as what you want, perhaps the rendering code for that block might give you clues?

 

-TGG

 

the other custom rendered block use for example

 

this.setRenderBounds(0.3125D, 0.0D, 0.0D, 0.6875D, 0.8125D, 1.0D);

this.renderStandardBlock(par1BlockWall, par2, par3, par4);

 

instead of tessellating, so it will render a standard block shaped as the block bounds

but in my code i use tessellator and different textures for each (almost each) faces, so it is more difficult... does anyone have an answer?

Actually i don't know what to write in this signature soooo.... anyway

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • *** buffer overflow detected ***: terminated /usr/bin/forge-1.12.2d: line 162: 15787 Aborted                 (core dumped) ${SUDO_CMD} screen -S "${SESSION_NAME}" -Q select . > /dev/null Starting server...There are several suitable screens on:     14630.forge-1.12.2    (Detached)     15796.forge-1.12.2    (Detached) Use -S to specify a session How do i fix this issue?
    • Oh I forgot to update the title. I figured out the issue and I'm rather embarrassed to say that it was a file path issue. The game already knew I was accessing the achievements so I wasn't suppose to include advancements in the file path. Minecraft file paths have always confused me a little bit... ResourceLocation advancementId = new ResourceLocation( TheDeadRise.MODID,"adventure/spawntrigger");
    • Can someone help my with this? My forge server won't open and I'm not that good with this stuff. It gave me this error message:   C:\Users\apbeu\Desktop\Forge server>java -Xmx4G -Xms1G -jar server.jar nogui 2024-12-11 18:21:01,054 main WARN Advanced terminal features are not available in this environment [18:21:01] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.2.34, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [18:21:01] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.1.3+8.1.3+main-8.1.x.c94d18ec starting: java version 21.0.4 by Oracle Corporation Exception in thread "main" java.lang.IllegalAccessError: class cpw.mods.modlauncher.SecureJarHandler (in unnamed module @0x402e37bc) cannot access class sun.security.util.ManifestEntryVerifier (in module java.base) because module java.base does not export sun.security.util to unnamed module @0x402e37bc         at cpw.mods.modlauncher.SecureJarHandler.lambda$static$1(SecureJarHandler.java:45)         at cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck(LamdbaExceptionUtils.java:95)         at cpw.mods.modlauncher.SecureJarHandler.<clinit>(SecureJarHandler.java:45)         at cpw.mods.modlauncher.Launcher.lambda$new$6(Launcher.java:55)         at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)         at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:52)         at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:47)         at cpw.mods.modlauncher.Environment.computePropertyIfAbsent(Environment.java:62)         at cpw.mods.modlauncher.Launcher.<init>(Launcher.java:55)         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66)         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63)         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60)         at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) C:\Users\apbeu\Desktop\Forge server>pause
    • Here is the url for the crash report if anyone can help me, please. https://mclo.gs/KGn5LWy  
    • Every single time I try and open my modpack it crashes before the game fully opens and I don't know what is wrong. I open the crash logs but I don't understand what any of it means. What do I do?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.