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.

[Solved][1.12] Ignoring light/lack of light in TESR using Tesselator

Featured Replies

Posted

Heya. 

 

I'm working on a TileEntity and since it's something that's rarely used I wanted to add a moving part to it that always turned towards you regardless of where you were. For this I used the Tesselator and TESR using GlStatemanager to make sure it always rotates towards the player.

 

code here: 

public class TESRHenge extends TileEntitySpecialRenderer<TileEntityHenge> {
    @Override
    public void render(TileEntityHenge te, double x, double y, double z, float partialTicks, int destroyStage, float alpha){
            GlStateManager.enableRescaleNormal();
            GlStateManager.pushMatrix();
            GlStateManager.enableBlend();
            GlStateManager.translate(x+0.5, y+0.5 , z+0.5);
            GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
            GlStateManager.rotate((float)(Minecraft.getMinecraft().getRenderManager().playerViewX == 2 ? -1 : 1) * Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
            GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
            GlStateManager.scale(0.6, 0.6, 0.6);
            Tessellator tess = Tessellator.getInstance();
            BufferBuilder buff = tess.getBuffer();
            Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(Main.MODID + ":" + "textures/modeltex/sphere.png"));
            buff.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            buff.pos(-0.5, -0.5, 0.0D).tex(1, 1).color(1.0F, 1.0F, 1.0F, 1F).endVertex();
            buff.pos(0.5, -0.5, 0.0D).tex(0, 1).color(1.0F, 1.0F, 1.0F, 1F).endVertex();
            buff.pos(0.5,0.5, 0.0).tex(0, 0).color(1.0F, 1.0F, 1.0F, 1F).endVertex();
            buff.pos(-0.5,0.5, 0.0).tex(1, 0).color(1.0F, 1.0F, 1.0F, 1F).endVertex();
            tess.draw();
            GlStateManager.popMatrix();
            GlStateManager.disableRescaleNormal();
            GlStateManager.disableBlend();
    }

 

As a disclaimer: I have never used the Tessellator before. It took me about an hour of experimenting before I realized I needed to draw the four corners. I'm also still reading into GlStateManager

 

 

The thing is, I want this spawned 'particle' to completely ignore lighting and always be at maximum brightness. I've tried using GlStateManager.disableLighting and Enablelighting. I'm just not quite sure what each one does. 

 

Anyhow. Seems the easiest way would be to simply make my block be a light source. But I'd rather not do that. I feel like there should be a way here. Am I supposed to use GlStateManager for this or should I somehow implement a lightmap into my Tessellator? How would I start doing this?

 

If anyone could point me in the right direction that'd be great.

 

 

Edit: I'm not very smart. There's a function for this in the TESR class itself.

Edited by oldcheese
solved

TileEntitySpecialRenderer has a method called setLightmapDisabled that allows you to disable and enable lighting. The lighting in GlStateManager causes your polygons to be shaded slightly darker on the sides and bottom.

  • Author

Welp. I was so entranced in trying to figure out how to properly rotate, transform and add vertexes that I forgot to look at the actual TESR class.

 

That definitely did the trick. Thanks.

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.