Jump to content

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


Tessa

Recommended Posts

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...

Important Information

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