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.

[1.15.2] Trying to render custom sun and moon textures in new dimension.

Featured Replies

Posted

I've been trying to use a custom sky renderer to change the sun and moon textures in my dimension. 
Everything works fine, but I can't figure out how to render the textures in "world space" if that makes sense. Everything just rotates with the view of the player.
This is the code I have in the render function of my IRenderHandler implementation.
 

	@Override
	public void render(int ticks, float partialTicks, ClientWorld world, Minecraft mc) {
		BufferBuilder bufferbuilder = Tessellator.getInstance().getBuffer();
		Tessellator tessellator = Tessellator.getInstance();	
		
        GlStateManager.enableTexture();
        GlStateManager.enableBlend();
        GlStateManager.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO);
        GL11.glPushMatrix();
        
        float alpha = 1.0F - world.getRainStrength(partialTicks);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha);
        GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
        
        float size = 100.0F;
        mc.getTextureManager().bindTexture(SUN_TEXTURES);
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
        bufferbuilder.pos((double)(-size), 100.0D, (double)(-size)).tex(0.0F, 0.0F).endVertex();
        bufferbuilder.pos((double)size, 100.0D, (double)(-size)).tex(1.0F, 0.0F).endVertex();
        bufferbuilder.pos((double)size, 100.0D, (double)size).tex(1.0F, 1.F).endVertex();
        bufferbuilder.pos((double)(-size), 100.0D, (double)size).tex(0.0F, 1.0F).endVertex();
        tessellator.draw();
        
        size = 100.0F;
        mc.getTextureManager().bindTexture(MOON_PHASES_TEXTURES);
        int k1 = world.getMoonPhase();
        int i2 = k1 % 4;
        int k2 = k1 / 4 % 2;
        float f22 = (float)(i2 + 0) / 4.0F;
        float f23 = (float)(k2 + 0) / 2.0F;
        float f24 = (float)(i2 + 1) / 4.0F;
        float f14 = (float)(k2 + 1) / 2.0F;
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
        bufferbuilder.pos((double)(-size), -100.0D, (double)size).tex(f24, f14).endVertex();
        bufferbuilder.pos((double)size, -100.0D, (double)size).tex(f22, f14).endVertex();
        bufferbuilder.pos((double)size, -100.0D, (double)(-size)).tex(f22, f23).endVertex();
        bufferbuilder.pos((double)(-size), -100.0D, (double)(-size)).tex(f24, f23).endVertex();
        tessellator.draw();
        
        GlStateManager.disableTexture();
        GL11.glPopMatrix();
	}

 

Screenshot 2020-12-09 095000.png

Edited by Tessa

If it rotates with the player, have you thought of rotating the rendering by -player's rotation?

Have you ever want the new operator to return a type that you didn't ask for? Well, now you can!

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.