Posted November 10, 20186 yr So, I have this code here, that is supposed to render my custom model. public class RenderAura extends Render implements IRenderFactory<EntityAura> { ModelBase model; public RenderAura(RenderManager renderManager) { super(renderManager); this.model = new ModelAura(); } @Nullable @Override protected ResourceLocation getEntityTexture(Entity entity) { return new ResourceLocation(References.MOD_ID, "textures/entity/aura.png"); } public void doRender(Entity entity, double x, double y, double z, float yaw, float pitch) { int[] AuraColor = entity.getCapability(ModCapabilities.AURA, null).getAuraColor(); float[] color = new float[AuraColor.length]; for(int i=0; i<AuraColor.length; i++) { color[i] = AuraColor[i]/10; } GL11.glPushMatrix();{ GL11.glScaled(0.5, 0.5, 0.5); GL11.glColor4f(0.58f, 0.110f, 0.193f, 0.4f); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(x, y, z); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 128.0F, 128.0F); bindTexture(new ResourceLocation(References.MOD_ID, "textures/entity/aura.png")); this.model.render(entity, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); GL11.glPopAttrib(); } GL11.glPopMatrix(); } @Override public Render<? super EntityAura> createRenderFor(RenderManager manager) { return new RenderAura(manager); } } As you can see by the title, I want a color that changes. Whenever I try to get it to work, it fails to apply the color. I've tried various different methods in an attempt to get it to work The Alpha works perfectly, however the color of the texture does not.
November 11, 20186 yr 1 hour ago, NolValue said: GL11 Don't access OpenGL methods directly, use GlStateManager. 1 hour ago, NolValue said: glPushAttrib ...why? Is the color not being applied at all, or is it not changing based on the values of the capability? If it's the latter you likely don't have those values synced to the client.
November 11, 20186 yr Author Went ahead and tried using GLStateManager, doesn't even render now. Anyways, the color is just straight up not applying
November 11, 20186 yr Author Also, I should mention that this isn't a for a TileEntity, this is a regular entity using a custom model.
November 11, 20186 yr 41 minutes ago, NolValue said: Went ahead and tried using GLStateManager, doesn't even render now. Post your updated code.
November 11, 20186 yr Author public class RenderAura extends Render implements IRenderFactory<EntityAura> { ModelBase model; public RenderAura(RenderManager renderManager) { super(renderManager); this.model = new ModelAura(); } @Nullable @Override protected ResourceLocation getEntityTexture(Entity entity) { return new ResourceLocation(References.MOD_ID, "textures/entity/aura.png"); } public void doRender(Entity entity, double x, double y, double z, float yaw, float pitch) { int[] AuraColor = entity.getCapability(ModCapabilities.AURA, null).getAuraColor(); float[] color = new float[AuraColor.length]; for(int i=0; i<AuraColor.length; i++) { color[i] = AuraColor[i]/10; } GlStateManager.pushAttrib(); GlStateManager.pushMatrix(); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); GlStateManager.translate(x, y, z); GlStateManager.color(0.259f, 0.525f, 0.957f, 0.4f); this.model.render(entity, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); GlStateManager.popAttrib(); } @Override public Render<? super EntityAura> createRenderFor(RenderManager manager) { return new RenderAura(manager); } } Edited November 11, 20186 yr by NolValue
November 11, 20186 yr 18 minutes ago, NolValue said: GlStateManager.pushAttrib(); Don't do this. First of all you don't need to do this. It also cases state leaks. 19 minutes ago, NolValue said: GlStateManager.enableBlend(); If you are enabling blend then specify the blend function too, you never know what it was set to beforehand. 19 minutes ago, NolValue said: GlStateManager.enableAlpha(); Same here, actually. Maybe not as relevant in minecraft since hardly anyone changes the alpha test function but you never know.
November 11, 20186 yr Author 5 minutes ago, V0idWa1k3r said: Don't do this. First of all you don't need to do this. It also cases state leaks. If you are enabling blend then specify the blend function too, you never know what it was set to beforehand. Same here, actually. Maybe not as relevant in minecraft since hardly anyone changes the alpha test function but you never know. Even with both of those done, the Entity plain refuses to load the model in. Works just fine with regular GL11, but not GLState
November 11, 20186 yr 7 minutes ago, NolValue said: Works just fine with regular GL11, but not GLState Then your doing something very wrong About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
November 11, 20186 yr Author 1 hour ago, Cadiboo said: Then your doing something very wrong Apparently, it's decided to do that thing where it only renders when the camera is in certain positions. And other entities aren't visible behind it Edited November 11, 20186 yr by NolValue
November 11, 20186 yr Your using the wrong blend function (or maybe not using depth correctly). Have a look at what happens when you look at water through your object. Take a look at https://github.com/Cadiboo/WIPTech/blob/2d7e3f1073ed5602944e35daccf18ced8ff4f40a/src/main/java/cadiboo/wiptech/client/render/tileentity/TESRAssemblyTable.java#L19-L22 and https://github.com/Cadiboo/WIPTech/blob/2d7e3f1073ed5602944e35daccf18ced8ff4f40a/src/main/java/cadiboo/wiptech/client/render/tileentity/TESRTurbine.java#L18-L19 About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
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.