Posted April 17, 201411 yr Hey everyone, I've been looking around, and I couldn't find a tutorial for rendering the overlay on a block that worked for 1.7.2. I thought that maybe I could look in Mojang's code for this, but I couldn't find the specialRenderer for the grass block (which is what I assume they are using for rendering the side of the grass block). If anyone could point me to either of the two (I'd prefer the grass block so I could figure it out myself) that would be great. Thanks!
April 17, 201411 yr It is at: /net/minecraft/client/renderer/RenderBlocks.class starting at line ~5100... PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.
April 18, 201411 yr Author Cool! Thanks! EDIT: Okay, so I did some looking around, and figured I could just render the two textures, with one on top of the other. Only problem is, sometimes texture A like to get rendered before texture B. Is there a way to make sure that texture A get rendered before texture B and not the other way around? Here is the code I am using to render the block right now. @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { renderer.renderFaceYPos(block, x,y,z, block.getIcon(1, world.getBlockMetadata(x, y, z))); renderer.renderFaceYPos(block, x,y,z, block.getIcon(world, x,y,z, 1)); return true; } I am using an ISimpleBlockRenderingHandler, so this method is getting called. I just need it (as mentioned before) to render some textures before others. Sometimes it does, other times it doesn't. Thanks!
April 18, 201411 yr Author Okay, so I found a slightly cheaty solution: @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { Tessellator.instance.setColorOpaque_F(1F,1F,1F); Tessellator.instance.addTranslation(0F, .01F, 0F); renderer.renderFaceYPos(block, x,y,z, block.getIcon(world, x,y,z, 1)); Tessellator.instance.addTranslation(0F, -.01F, 0F); renderer.renderFaceYPos(block, x, y, z, DummyBlockScrolls.getUnderlayer()); return true; } Essentially, you put one texture slightly over another. Works decent. But now I have another question (still related to this). I want to make the underlayer glow, but not the over layer. How would I stop the over layer from glowing? I know I can make them both glow by using: Tessellator.instance.setBrightness(brightness); If I set it at zero both texture become black, if I set it to say 200, both have the appearance of glowing. How would I get the top layer to be normal and the bottom layer to have that code added to it? I thought maybe a switch statement might work, but I couldn't figure out what to switch between...
April 19, 201411 yr Okay, so I found a slightly cheaty solution: @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { Tessellator.instance.setColorOpaque_F(1F,1F,1F); Tessellator.instance.addTranslation(0F, .01F, 0F); renderer.renderFaceYPos(block, x,y,z, block.getIcon(world, x,y,z, 1)); Tessellator.instance.addTranslation(0F, -.01F, 0F); renderer.renderFaceYPos(block, x, y, z, DummyBlockScrolls.getUnderlayer()); return true; } Essentially, you put one texture slightly over another. Works decent. But now I have another question (still related to this). I want to make the underlayer glow, but not the over layer. How would I stop the over layer from glowing? I know I can make them both glow by using: Tessellator.instance.setBrightness(brightness); If I set it at zero both texture become black, if I set it to say 200, both have the appearance of glowing. How would I get the top layer to be normal and the bottom layer to have that code added to it? I thought maybe a switch statement might work, but I couldn't figure out what to switch between... Like this: https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/sanandreasp/core/manpack/helpers/client/RenderBlockGlowOverlay.java#L106-L126 Basically I render the block (which is not glowing), set the brightness to 240 (max brightness), then rendered the glowing texture and last but not least reset the brightness. In your case it's vice versa (set brightness, render glowy texture, reset brightness, render standard block) Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
April 19, 201411 yr Author It... Works... Kind of.... It is rendering the layers funny. The two textures are also fighting for control over who gets top layer. Did I do something wrong? @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { DummyBlockScrolls dummy = (DummyBlockScrolls)block; renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, 1F, 1F, 1F); if( block instanceof DummyBlockScrolls ) { Tessellator.instance.setBrightness(240); Tessellator.instance.setColorOpaque(255, 255, 255); renderer.renderFaceYNeg(block, x, y, z, dummy.getUnderlayer()); renderer.renderFaceYPos(block, x, y, z, dummy.getUnderlayer()); renderer.renderFaceZNeg(block, x, y, z, dummy.getUnderlayer()); renderer.renderFaceZPos(block, x, y, z, dummy.getUnderlayer()); renderer.renderFaceXNeg(block, x, y, z, dummy.getUnderlayer()); renderer.renderFaceXPos(block, x, y, z, dummy.getUnderlayer()); Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); } return true; }
April 20, 201411 yr That's a typical example of z-fighting. If you have two textures that render in the same exact plane, the graphics engine renders them as fighting for dominance and can cause weird effects. If I were doing this, I'd render them in parallel planes but with a small distance between them. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
April 21, 201411 yr Author Yeah, I thought that might be what I needed done, but that produces another problem, if one side of a block stops rendering, and I slowly turn to look at it, only the underlayer renders..
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.