Tessa Posted December 9, 2020 Posted December 9, 2020 (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(); } Edited December 9, 2020 by Tessa Quote
Vinyarion Posted December 10, 2020 Posted December 10, 2020 If it rotates with the player, have you thought of rotating the rendering by -player's rotation? Quote Have you ever want the new operator to return a type that you didn't ask for? Well, now you can!
Recommended Posts
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.