Jump to content

[1.8] TESR renders correct shape, but is solid black, no texture


GalianRyu

Recommended Posts

So I have a TileEntitySpecialRenderer set up and I did everything pretty much the same way I did my last TESR, but for some reason it renders the shape correctly, but doesn't have the texture, or even the purple/black default texture, its just solid black.  I have double and triple checked that the Resource Location is correct and there's no typo in the filepath, and I even made certain that it was seeing the correct textures after each drawing.

 

Here's the code for the renderer:

package net.rpcraft.rpcraft;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.rpcraft.rpcraft.RPSpikes.TileEntitySpikes;


public class TileEntitySpikesRenderer extends TileEntitySpecialRenderer
{
private ResourceLocation spikeTexture;
private ResourceLocation bottomTexture;

@Override
public void renderTileEntityAt(TileEntity tileEntityIn, double posX, double posY, double posZ, float partialTick, int damage) 
{
	if(!(tileEntityIn instanceof TileEntitySpikes))
		return;

	TileEntitySpikes tileEntity = (TileEntitySpikes)tileEntityIn;

	if(tileEntity.getBlockMetadata() == 0)
	{
		spikeTexture = new ResourceLocation(RPCraft.MODID, "textures/blocks/spikesNormal.png");
		bottomTexture = new ResourceLocation(RPCraft.MODID, "textures/blocks/spikesNormal.png");
	}
	else if(tileEntity.getBlockMetadata() == 1)
	{
		spikeTexture = new ResourceLocation(RPCraft.MODID, "textures/blocks/spikesStained.png");
		bottomTexture = new ResourceLocation(RPCraft.MODID, "textures/blocks/spikesNormal.png");
	}
	else if(tileEntity.getBlockMetadata() == 2)
	{
		spikeTexture = new ResourceLocation(RPCraft.MODID, "textures/blocks/spikesDarkened.png");
		bottomTexture = new ResourceLocation(RPCraft.MODID, "textures/blocks/spikesDarkened.png");
	}
	else if(tileEntity.getBlockMetadata() == 3)
	{
		spikeTexture = new ResourceLocation(RPCraft.MODID, "textures/blocks/spikesDarkAndStained.png");
		bottomTexture = new ResourceLocation(RPCraft.MODID, "textures/blocks/spikesDarkened.png");
	}
	else
	{
		spikeTexture = new ResourceLocation(RPCraft.MODID, "textures/blocks/spikesNormal.png");
		bottomTexture = new ResourceLocation(RPCraft.MODID, "textures/blocks/spikesNormal.png");
	}

	Tessellator tess = Tessellator.getInstance();
    WorldRenderer worldrenderer = tess.getWorldRenderer();

	GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    
    this.bindTexture(spikeTexture);
    
    GlStateManager.translate(posX, posY, posZ);
    worldrenderer.startDrawing(4);
    TriangleVertices(worldrenderer);
    tess.draw();
    
    this.bindTexture(bottomTexture);
    worldrenderer.startDrawingQuads();
    worldrenderer.addVertexWithUV(1.0D, 0.0D, 0.0D, 1.0D, 1.0D);
    worldrenderer.addVertexWithUV(1.0D, 0.0D, 1.0D, 1.0D, 0.0D);
    worldrenderer.addVertexWithUV(0.0D, 0.0D, 1.0D, 0.0D, 0.0D);
    worldrenderer.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 1.0D);
    tess.draw();

	GL11.glPopAttrib();
	GL11.glPopMatrix();
}

private void TriangleVertices(WorldRenderer worldrenderer)
{
	worldrenderer.addVertexWithUV(1.0D, 0.0D, 1.0D, 1.0D, 1.0D);
	worldrenderer.addVertexWithUV(0.75D, 1.0D, 0.75D, 0.75D, 0.0D);
	worldrenderer.addVertexWithUV(0.5D, 0.0D, 1.0D, 0.5D, 1.0D);

	worldrenderer.addVertexWithUV(0.5D, 0.0D, 1.0D, 0.5D, 1.0D);
	worldrenderer.addVertexWithUV(0.25D, 1.0D, 0.75D, 0.25D, 0.0D);
	worldrenderer.addVertexWithUV(0.0D, 0.0D, 1.0D, 0.0D, 1.0D);

	worldrenderer.addVertexWithUV(1.0D, 0.0D, 0.5D, 1.0D, 1.0D);
	worldrenderer.addVertexWithUV(0.75D, 1.0D, 0.25D, 0.75D, 0.0D);
	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.5D, 0.5D, 1.0D);

	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.5D, 0.5D, 1.0D);
	worldrenderer.addVertexWithUV(0.25D, 1.0D, 0.25D, 0.25D, 0.0D);
	worldrenderer.addVertexWithUV(0.0D, 0.0D, 0.5D, 0.0D, 1.0D);

	worldrenderer.addVertexWithUV(0.0D, 0.0D, 0.0D, 1.0D, 1.0D);
	worldrenderer.addVertexWithUV(0.25D, 1.0D, 0.25D, 0.75D, 0.0D);
	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.0D, 0.5D, 1.0D);

	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.0D, 0.5D, 1.0D);
	worldrenderer.addVertexWithUV(0.75D, 1.0D, 0.25D, 0.25D, 0.0D);
	worldrenderer.addVertexWithUV(1.0D, 0.0D, 0.0D, 0.0D, 1.0D);

	worldrenderer.addVertexWithUV(0.0D, 0.0D, 0.5D, 1.0D, 1.0D);
	worldrenderer.addVertexWithUV(0.25D, 1.0D, 0.75D, 0.75D, 0.0D);
	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.5D, 0.5D, 1.0D);

	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.5D, 0.5D, 1.0D);
	worldrenderer.addVertexWithUV(0.75D, 1.0D, 0.75D, 0.25D, 0.0D);
	worldrenderer.addVertexWithUV(1.0D, 0.0D, 0.5D, 0.0D, 1.0D);

	worldrenderer.addVertexWithUV(1.0D, 0.0D, 0.0D, 1.0D, 1.0D);
	worldrenderer.addVertexWithUV(0.75D, 1.0D, 0.25D, 0.75D, 0.0D);
	worldrenderer.addVertexWithUV(1.0D, 0.0D, 0.5D, 0.5D, 1.0D);

	worldrenderer.addVertexWithUV(1.0D, 0.0D, 0.5D, 0.5D, 1.0D);
	worldrenderer.addVertexWithUV(0.75D, 1.0D, 0.75D, 0.25D, 0.0D);
	worldrenderer.addVertexWithUV(1.0D, 0.0D, 1.0D, 0.0D, 1.0D);

	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.0D, 1.0D, 1.0D);
	worldrenderer.addVertexWithUV(0.25D, 1.0D, 0.25D, 0.75D, 0.0D);
	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.5D, 0.5D, 1.0D);

	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.5D, 0.5D, 1.0D);
	worldrenderer.addVertexWithUV(0.25D, 1.0D, 0.75D, 0.25D, 0.0D);
	worldrenderer.addVertexWithUV(0.5D, 0.0D, 1.0D, 0.0D, 1.0D);

	worldrenderer.addVertexWithUV(0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
	worldrenderer.addVertexWithUV(0.25D, 1.0D, 0.75D, 0.75D, 0.0D);
	worldrenderer.addVertexWithUV(0.0D, 0.0D, 0.5D, 0.5D, 1.0D);

	worldrenderer.addVertexWithUV(0.0D, 0.0D, 0.5D, 0.5D, 1.0D);
	worldrenderer.addVertexWithUV(0.25D, 1.0D, 0.25D, 0.25D, 0.0D);
	worldrenderer.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 1.0D);

	worldrenderer.addVertexWithUV(0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
	worldrenderer.addVertexWithUV(0.75D, 1.0D, 0.75D, 0.75D, 0.0D);
	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.5D, 0.5D, 1.0D);

	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.5D, 0.5D, 1.0D);
	worldrenderer.addVertexWithUV(0.75D, 1.0D, 0.25D, 0.25D, 0.0D);
	worldrenderer.addVertexWithUV(0.5D, 0.0D, 0.0D, 0.0D, 1.0D);
}
}

 

So far the block is just extending blockContainer and the TileEntity is literally just

 

public static class TileEntitySpikes extends TileEntity {}

 

since I only needed it for the renderer.  Did I miss something?

Check out my Mod: The RPCraft Toolkit!

Link to comment
Share on other sites

I had something like that happen when I updated 1.7 to 1.8 for a renderer for custom paintings. It turned out to be light level (everything is black if your light level function returns zero).

 

I had been calling the wrong function to get the illumination level for each tile's pos. I ended up calling this.renderManager.worldObj.getCombinedLight(...). Find where you're setting light level and compare your light source to what's used in a comparable vanilla renderer.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Well, as you can see from my code, I haven't overridden any functions that control light level.  Do you know where the light level is usually controlled from so I can attempt to locate the default function or emulate it?

 

I checked the vanilla code for chests and skulls, but found no functions that resembled yours or looked obviously related to light level.

Check out my Mod: The RPCraft Toolkit!

Link to comment
Share on other sites

Found what I was missing!

 

Even though blockContainer overrides the standard render rules with getRenderType() return -1...

 

You still have to override IsOpaqueCube yourself to return false.  Seems like BlockContainer should do that as well, since your only going to use a TESR for something not cube-like lol.

Check out my Mod: The RPCraft Toolkit!

Link to comment
Share on other sites

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.