Posted April 1, 201312 yr Hey guys. So, I have an ISimpleBlockRenderingHandler that renders a block, and I wasnt to make it render upside down... what would the easiest way to this be? It uses the tesselator and all that and draws all the points so.. idk.. I have tried things like glRotate and all that and nothing seems to work. If anyone knows how to do this, PLEASE let me know! THX!
April 1, 201312 yr Draw the points in a different order. Specifically, you might want to look at the last value passed....the texture V (as in, swap it). Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
April 1, 201312 yr ...Simpler? Simpler than swapping two variables? Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
April 1, 201312 yr Author ok fair enough, but first of all.. texture V ?? there are things like setRenderBounds, setOverrideBlockTexture, setNormal, renderBottomFace, draw, startDrawingQuads, etc... so .. here, ill post the code package mods.UpwardsHopper; import org.lwjgl.opengl.GL11; import net.minecraft.block.Block; import net.minecraft.block.BlockHopper; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderUpwardsHopper implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { if(block instanceof BlockUpwardsHopper) { return renderBlockHopper(Block.hopperBlock, x, y, z, world, renderer); } return false; } @Override public boolean shouldRender3DInInventory() { return false; } @Override public int getRenderId() { return UpwardsHopper.instance.hopperRenderID; } public boolean renderBlockHopper(BlockHopper par1BlockHopper, int par2, int par3, int par4, IBlockAccess blockAccess, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; tessellator.setBrightness(par1BlockHopper.getMixedBrightnessForBlock(blockAccess, par2, par3, par4)); float f = 1.0F; int l = par1BlockHopper.colorMultiplier(blockAccess, par2, par3, par4); float f1 = (float) (l >> 16 & 255) / 255.0F; float f2 = (float) (l >> 8 & 255) / 255.0F; float f3 = (float) (l & 255) / 255.0F; if(EntityRenderer.anaglyphEnable) { float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F; float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F; f1 = f4; f2 = f5; f3 = f6; } tessellator.setColorOpaque_F(f * f1, f * f2, f * f3); return renderBlockHopperMetadata(par1BlockHopper, par2, par3, par4, blockAccess.getBlockMetadata(par2, par3, par4), false, renderer); } public boolean renderBlockHopperMetadata(BlockHopper par1BlockHopper, int par2, int par3, int par4, int par5, boolean par6, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; int i1 = BlockHopper.func_94451_c(par5); double d0 = 0.625D; renderer.setRenderBounds(0.0D, d0, 0.0D, 1.0D, 1.0D, 1.0D); if(par6) { tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1.0F, 0.0F); renderer.renderBottomFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 0, par5)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderer.renderTopFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 1, par5)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1.0F); renderer.renderEastFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 2, par5)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderer.renderWestFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 3, par5)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1.0F, 0.0F, 0.0F); renderer.renderNorthFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 4, par5)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderer.renderSouthFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 5, par5)); tessellator.draw(); } else { renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4); } float f; if(!par6) { tessellator.setBrightness(par1BlockHopper.getMixedBrightnessForBlock(renderer.blockAccess, par2, par3, par4)); float f1 = 1.0F; int j1 = par1BlockHopper.colorMultiplier(renderer.blockAccess, par2, par3, par4); f = (float) (j1 >> 16 & 255) / 255.0F; float f2 = (float) (j1 >> 8 & 255) / 255.0F; float f3 = (float) (j1 & 255) / 255.0F; if(EntityRenderer.anaglyphEnable) { float f4 = (f * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; float f6 = (f * 30.0F + f3 * 70.0F) / 100.0F; f = f4; f2 = f5; f3 = f6; } tessellator.setColorOpaque_F(f1 * f, f1 * f2, f1 * f3); } Icon icon = BlockHopper.func_94453_b("hopper"); Icon icon1 = BlockHopper.func_94453_b("hopper_inside"); f = 0.125F; if(par6) { tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderer.renderSouthFace(par1BlockHopper, (double) (-1.0F + f), 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1.0F, 0.0F, 0.0F); renderer.renderNorthFace(par1BlockHopper, (double) (1.0F - f), 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderer.renderWestFace(par1BlockHopper, 0.0D, 0.0D, (double) (-1.0F + f), icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1.0F); renderer.renderEastFace(par1BlockHopper, 0.0D, 0.0D, (double) (1.0F - f), icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderer.renderTopFace(par1BlockHopper, 0.0D, -1.0D + d0, 0.0D, icon1); tessellator.draw(); } else { renderer.renderSouthFace(par1BlockHopper, (double) ((float) par2 - 1.0F + f), (double) par3, (double) par4, icon); renderer.renderNorthFace(par1BlockHopper, (double) ((float) par2 + 1.0F - f), (double) par3, (double) par4, icon); renderer.renderWestFace(par1BlockHopper, (double) par2, (double) par3, (double) ((float) par4 - 1.0F + f), icon); renderer.renderEastFace(par1BlockHopper, (double) par2, (double) par3, (double) ((float) par4 + 1.0F - f), icon); renderer.renderTopFace(par1BlockHopper, (double) par2, (double) ((float) par3 - 1.0F) + d0, (double) par4, icon1); } renderer.setOverrideBlockTexture(icon); double d1 = 0.25D; double d2 = 0.25D; renderer.setRenderBounds(d1, d2, d1, 1.0D - d1, d0 - 0.002D, 1.0D - d1); if(par6) { tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderer.renderSouthFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1.0F, 0.0F, 0.0F); renderer.renderNorthFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderer.renderWestFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1.0F); renderer.renderEastFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderer.renderTopFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1.0F, 0.0F); renderer.renderBottomFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); } else { renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4); } if(!par6) { double d3 = 0.375D; double d4 = 0.25D; renderer.setOverrideBlockTexture(icon); if(i1 == 0) { renderer.setRenderBounds(d3, 0.0D, d3, 1.0D - d3, 0.25D, 1.0D - d3); renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4); } if(i1 == 2) { renderer.setRenderBounds(d3, d2, 0.0D, 1.0D - d3, d2 + d4, d1); renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4); } if(i1 == 3) { renderer.setRenderBounds(d3, d2, 1.0D - d1, 1.0D - d3, d2 + d4, 1.0D); renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4); } if(i1 == 4) { renderer.setRenderBounds(0.0D, d2, d3, d1, d2 + d4, 1.0D - d3); renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4); } if(i1 == 5) { renderer.setRenderBounds(1.0D - d1, d2, d3, 1.0D, d2 + d4, 1.0D - d3); renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4); } } renderer.clearOverrideBlockTexture(); return true; } } I suppose its not a big deal if its stolen.. probably not an original idea anyway.. meh.
April 1, 201312 yr Ah, I see, you're using the built in render[direction]Face fucntions. Yeah. You're going to need to duplicate those and change them. You're looking for this: tessellator.addVertexWithUV(var28, var34, var36, var20, var24); Note five variables are passed. They are, in order: X, Y, Z, U, V. XYZ should be fairly obvious. It's the coordinate in space the vertex is located at. Typically they vary from block.posX to block.posX+1 (same for Y and Z, modified by bounds). U and V relate to the texture. U is a horizontal (x axis) position on the texture, V is the vertical (y axis) position. You need to duplicate the renderFace functions for the sides you want flipped, then swap the variables passed to the V parameter with each other (eg. if the four verts use var23 and var24 you'd change them to be the other). Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
April 1, 201312 yr Author hmm.. all it did was make the inside of the hopper look like pink wool..... uhm... i did something wrong?!?! edit: renderer.renderStandardBlock is being called...
April 1, 201312 yr hmm.. all it did was make the inside of the hopper look like pink wool..... uhm... i did something wrong?!?! edit: renderer.renderStandardBlock is being called... You might want to build the renderer yourself, rather than relying on the prebuilt functions. It's not that difficult, really. At least, for cubes. I'll dig up some code I have for a custom renderer I have when I get home. It is basically what you need, just you have to swap some variables around. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
April 1, 201312 yr Author .. all i want is an upside down hopper lol... why cant glRotate work? would be a 1 or 2 line thing if glRotate worked for this...
April 2, 201312 yr Ah, I see, you're trying to do something more complicated than I expected. I thought you were trying to get a TEXTURE upside down. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
April 2, 201312 yr ... uh... well... so... can u help still? Not really no. :\ I've barely touched rendering. I've made a cube. :V Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.