Jump to content

Texture Not Changing To Assigned Color?


NolValue

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by NolValue
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.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)

Link to comment
Share on other sites

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.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)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.