GalianRyu Posted September 30, 2015 Posted September 30, 2015 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? Quote Check out my Mod: The RPCraft Toolkit!
jeffryfisher Posted September 30, 2015 Posted September 30, 2015 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. Quote 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.
GalianRyu Posted October 1, 2015 Author Posted October 1, 2015 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. Quote Check out my Mod: The RPCraft Toolkit!
GalianRyu Posted October 1, 2015 Author Posted October 1, 2015 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. Quote Check out my Mod: The RPCraft Toolkit!
Flenix Posted October 1, 2015 Posted October 1, 2015 since your only going to use a TESR for something not cube-like lol. Just for reference, I have a TESR block which is a full cube but just renders an item floating above it Quote http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
Recommended Posts
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.