Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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.

  • Author

Went ahead and tried using GLStateManager, doesn't even render now.

Anyways, the color is just straight up not applying

  • Author

Also, I should mention that this isn't a for a TileEntity, this is a regular entity using a custom model.

41 minutes ago, NolValue said:

Went ahead and tried using GLStateManager, doesn't even render now.

Post your updated code.

 

 

  • 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 by NolValue

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.

  • 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

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)

  • 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

2018-11-10_21.50.05.png

Edited by NolValue

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)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.