Bektor Posted April 11, 2016 Posted April 11, 2016 Hi, I'm currently having some problems with my render code for my block. I'm using Minecraft Forge 1.8.9. The renderer draws sometimes blocks like the water in a different colour when I'm coming near to my own block and moving there a bit around. Here is a picture of the problem: And a picture which shows how everything is rendered when I'm a bit farer away. (just moved a bit away from my block) The next point would be, when you are about 20 blocks from my block away it turns invisible, same goes when you are over the block (directly over it or farer away). It does not turn complete invisible at once, it's goes more that part of part of the block are turning invisible. Here is my TileEntityPortalRenderer: @SideOnly(Side.CLIENT) public class TileEntityPortalRenderer extends TileEntitySpecialRenderer<TileEntityPortal> { public static int sphereIDOutside; public static int sphereIDInside; @Override public void renderTileEntityAt(TileEntityPortal tileEntity, double posX, double posY, double posZ, float partialTicks, int destroyStage) { GlStateManager.pushMatrix(); // store the transformation GlStateManager.translate(posX, posY, posZ); // set viewport to tile entity position to render it /* ============ Rendering Code goes here ============ */ GlStateManager.translate(posX + 1f, posY - .6f, posZ + 1f); GlStateManager.enableBlend(); // enable rendering for transparency GlStateManager.depthMask(false); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.color(1.f, 1.f, 1.f, 1.f); GlStateManager.callList(TileEntityPortalRenderer.sphereIDOutside); GlStateManager.callList(TileEntityPortalRenderer.sphereIDInside); //renderLight(posX, posY, posZ); GlStateManager.resetColor(); GlStateManager.disableBlend(); /* ============ Rendering Code stops here =========== */ GlStateManager.popMatrix(); // restore the transformation, so other renderer's are not messed up } public static void createSphere() { Sphere sphere = new Sphere(); sphere.setDrawStyle(GLU.GLU_FILL); // fill as a solid sphere.setTextureFlag(true); sphere.setNormals(GLU.GLU_SMOOTH); // smooth everything // First make the call list for the outside of the sphere sphere.setOrientation(GLU.GLU_OUTSIDE); TileEntityPortalRenderer.sphereIDOutside = GL11.glGenLists(1); // Create a new list to hold our sphere data GL11.glNewList(TileEntityPortalRenderer.sphereIDOutside, GL11.GL_COMPILE); // binds the texture ResourceLocation resource = new ResourceLocation(Constants.MOD_ID + ":" + "textures/entities/sphere.png"); Minecraft.getMinecraft().getTextureManager().bindTexture(resource); sphere.draw(1.2f, 32, 32); GL11.glEndList(); // Make the call list for the inside of the sphere sphere.setOrientation(GLU.GLU_INSIDE); TileEntityPortalRenderer.sphereIDInside = GL11.glGenLists(1); // Create a new list to hold our sphere data GL11.glNewList(TileEntityPortalRenderer.sphereIDInside, GLU.GLU_INSIDE); Minecraft.getMinecraft().getTextureManager().bindTexture(resource); sphere.draw(1.2f, 32, 32); GL11.glEndList(); } } My init method in the ClientProxy which get's called at the end of the init method in the main class: @Override public void init() { super.init(); TileEntityPortalRenderer.createSphere(); } Here are my json files: blockstates { "variants": { "normal": { "model": "primevalforest:portal" } } } block { "parent": "block/generated", "textures": { "cross": "primevalforest:blocks/portal" } } item { "parent": "builtin/generated", "textures": { "layer0": "primevalforest:blocks/portal" }, "display": { "thirdperson": { "rotation": [ -90, 0, 0 ], "translation": [ 0, 1, -3 ], "scale": [ 0.55, 0.55, 0.55 ] }, "firstperson": { "rotation": [ 0, -135, 25 ], "translation": [ 0, 4, 2 ], "scale": [ 1.7, 1.7, 1.7 ] } } } I hope someone can help me. Thx in advance. Bektor Quote Developer of Primeval Forest.
DestinySpork Posted April 12, 2016 Posted April 12, 2016 Use an OBJ model both of these problems will be solved. Unless you need it to do special stuff. Quote
Bektor Posted April 12, 2016 Author Posted April 12, 2016 On 4/12/2016 at 5:28 PM, DestinySpork said: Use an OBJ model both of these problems will be solved. Unless you need it to do special stuff. I might be using obj's in the future, but this problem got my interest and I want to know what's wrong there at any price. ^^ Why do I want to fix this problem at any cost: because of all the OpenGL error's I'm getting and to fix them might help me also to better understand what's going on and how to fix it if I might get such errors outside of Minecraft, too. So I tracked down the issue yet a bit: // Make the call list for the inside of the sphere sphere.setOrientation(GLU.GLU_INSIDE); TileEntityPortalRenderer.sphereIDInside = GL11.glGenLists(1); // Create a new list to hold our sphere data GL11.glNewList(TileEntityPortalRenderer.sphereIDInside, GLU.GLU_INSIDE); Minecraft.getMinecraft().getTextureManager().bindTexture(resource); sphere.draw(1.2f, 32, 32); GL11.glEndList(); So, as seen above, removing this lines of code for the inner sphere removes the issue: [Client thread/ERROR]: @ Post render [Client thread/ERROR]: 1280: Invalid enum [Client thread/ERROR]: ########## GL ERROR ########## Now I've got only this code left in the createSphere method. I also removed the GlStateManager.color and GlStateManager.resetColor calls in renderTileEntityAt. public static void createSphere() { Sphere sphere = new Sphere(); sphere.setDrawStyle(GLU.GLU_FILL); // fill as a solid sphere.setTextureFlag(true); sphere.setNormals(GLU.GLU_SMOOTH); // smooth everything // First make the call list for the outside of the sphere sphere.setOrientation(GLU.GLU_OUTSIDE); TileEntityPortalRenderer.sphereIDOutside = GL11.glGenLists(1); // Create a new list to hold our sphere data GL11.glNewList(TileEntityPortalRenderer.sphereIDOutside, GL11.GL_COMPILE); // binds the texture ResourceLocation resource = new ResourceLocation(Constants.MOD_ID + ":" + "textures/entities/sphere.png"); Minecraft.getMinecraft().getTextureManager().bindTexture(resource); sphere.draw(1.2f, 32, 32); GL11.glEndList(); } So now I'm getting a new error. This error does not happen on start up, it happens only when the block is drawn: [Client thread/ERROR]: ########## GL ERROR ########## [Client thread/ERROR]: @ Post render [Client thread/ERROR]: 1281: Invalid value So something I did or a class I'm using for it is heavily broken. Any ideas what the error could be? Thx in advance. Bektor Quote Developer of Primeval Forest.
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.