Jump to content

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


Recommended Posts

Posted (edited)

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
Posted

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

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

Announcements



×
×
  • Create New...

Important Information

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