Jump to content

Recommended Posts

Posted

Hey Guys!

I want to render a special Block which looks like a Block of Glowstone which is inside a Block of Glass.

 

The problem is that only the Glass Block is rendered...

 

This is my Code:

 

@Override
public void renderInventoryBlock(Block block, int meta, int modelId, RenderBlocks renderer) {
    	IIcon c = block.getIcon(0, meta);
    	IIcon c1 = block.getIcon(1, meta);
    	
	Tessellator t = Tessellator.instance;
	GL11.glTranslatef(0.0F,  -0.1F, 0.0F);
	t.startDrawingQuads();
	t.setColorOpaque(255, 255, 255);

	render(t, c, c1);

	t.draw();
	GL11.glTranslatef(0.0F, 0.1F, 0.0F);
}

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	int meta = world.getBlockMetadata(x, y, z);
    	IIcon c = block.getIcon(0, meta);
    	IIcon c1 = block.getIcon(1, meta);
    	
	Tessellator t = Tessellator.instance;
	t.addTranslation(x, y, z);
	t.setColorOpaque_F(1.0F, 1.0F, 1.0F); t.setBrightness(255);

	render(t, c, c1);

	t.addTranslation(-x, -y, -z);
        return true;
}

@Override
public boolean shouldRender3DInInventory(int modelId) {
	return true;
}

protected static void renderCube(Tessellator t, float x, float y, float z, float X, float Y, float Z, IIcon icon)
{
    	float u = icon.getMinU();
    	float v = icon.getMinV();
    	float U = icon.getMaxU();
    	float V = icon.getMaxV();

	t.setColorOpaque_F(1.0F, 1.0F, 1.0F);

	//Bottom
	t.addVertexWithUV(x, y, Z, u, v);
	t.addVertexWithUV(x, y, z, u, V);
	t.addVertexWithUV(X, y, z, U, V);
	t.addVertexWithUV(X, y, Z, U, v);
	//West
	t.addVertexWithUV(x, Y, z, u, v);
	t.addVertexWithUV(x, y, z, u, V);
	t.addVertexWithUV(x, y, Z, U, V);
	t.addVertexWithUV(x, Y, Z, U, v);
	//North
	t.addVertexWithUV(X, Y, z, u, v);
	t.addVertexWithUV(X, y, z, u, V);
	t.addVertexWithUV(x, y, z, U, V);
	t.addVertexWithUV(x, Y, z, U, v);
	//East
	t.addVertexWithUV(X, y, Z, u, V);
	t.addVertexWithUV(X, y, z, U, V);
	t.addVertexWithUV(X, Y, z, U, v);
	t.addVertexWithUV(X, Y, Z, u, v);
	//Top
	t.addVertexWithUV(X, Y, z, u, v);
	t.addVertexWithUV(x, Y, z, u, V);
	t.addVertexWithUV(x, Y, Z, U, V);
	t.addVertexWithUV(X, Y, Z, U, v);
	//South
	t.addVertexWithUV(x, Y, Z, u, v);
	t.addVertexWithUV(x, y, Z, u, V);
	t.addVertexWithUV(X, y, Z, U, V);
	t.addVertexWithUV(X, Y, Z, U, v);
}

 

EDIT:

Sorry, just solved the Problem by swapping the two renderBlock methods.

New Problem: In the Inventory the Block is rendered much darker than in the world. If you have an Item in your hand it's even darker. (->Picture)

How can this Bug be fixed? I set brightness and opacity to default values so it must work, i thought.

 

Picture:

 

J7Ik2DE.png

 

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



×
×
  • Create New...

Important Information

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