Merge pull request #3 from d4rkfly3r/1.10-WIP

Fixing Limbo Sky
This commit is contained in:
Waterpicker 2017-04-28 23:54:14 -05:00 committed by GitHub
commit 75403cdbe9
4 changed files with 88 additions and 73 deletions

View file

@ -3,8 +3,8 @@ package com.zixiken.dimdoors.shared.world;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.*;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@ -15,11 +15,10 @@ import org.lwjgl.opengl.GL11;
public class CustomSkyProvider extends IRenderHandler { public class CustomSkyProvider extends IRenderHandler {
private static final ResourceLocation locationEndSkyPng = new ResourceLocation("textures/environment/end_sky.png");
int starGLCallList; int starGLCallList;
int glSkyList; int glSkyList;
int glSkyList2; int glSkyList2;
private static final ResourceLocation locationEndSkyPng = new ResourceLocation("textures/environment/end_sky.png");
public ResourceLocation getMoonRenderPath() { public ResourceLocation getMoonRenderPath() {
return null; return null;
@ -46,28 +45,35 @@ public class CustomSkyProvider extends IRenderHandler {
mc.renderEngine.bindTexture((locationEndSkyPng)); mc.renderEngine.bindTexture((locationEndSkyPng));
if (world.provider.isSurfaceWorld()) { if (mc.world.provider.isSurfaceWorld()) {
GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_2D);
Vec3d vec3 = world.getSkyColor(mc.getRenderViewEntity(), par1); final Vec3d vec3 = world.getSkyColor(mc.getRenderViewEntity(), par1);
float f1 = (float) vec3.xCoord; float f1 = (float) vec3.xCoord;
float f2 = (float) vec3.yCoord; float f2 = (float) vec3.yCoord;
float f3 = (float) vec3.zCoord; float f3 = (float) vec3.zCoord;
float f4; float f4;
if (mc.gameSettings.anaglyph) {
float f5 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
float f6 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
f4 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
f1 = f5;
f2 = f6;
f3 = f4;
}
GL11.glColor3f(f1, f2, f3); GL11.glColor3f(f1, f2, f3);
Tessellator tessellator = Tessellator.getInstance(); final Tessellator tessellator = Tessellator.getInstance();
VertexBuffer buffer = tessellator.getBuffer(); final VertexBuffer buffer = tessellator.getBuffer();
GL11.glDepthMask(false);
GlStateManager.depthMask(false); GL11.glEnable(GL11.GL_FOG);
GlStateManager.enableFog(); GL11.glColor3f(f1, f2, f3);
GlStateManager.color(f1, f2, f3); GL11.glCallList(this.glSkyList);
GlStateManager.callList(this.glSkyList); GL11.glDisable(GL11.GL_FOG);
GlStateManager.disableFog(); GL11.glDisable(GL11.GL_ALPHA_TEST);
GlStateManager.disableAlpha(); GL11.glEnable(GL11.GL_BLEND);
GlStateManager.enableBlend(); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(par1), par1); float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(par1), par1);
float f7; float f7;
float f8; float f8;
@ -75,56 +81,60 @@ public class CustomSkyProvider extends IRenderHandler {
float f10; float f10;
if (afloat != null) { if (afloat != null) {
GlStateManager.disableTexture2D(); GL11.glDisable(GL11.GL_TEXTURE_2D);
GlStateManager.shadeModel(GL11.GL_SMOOTH); GL11.glShadeModel(GL11.GL_SMOOTH);
GlStateManager.pushMatrix(); GL11.glPushMatrix();
GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(MathHelper.sin(world.getCelestialAngleRadians(par1)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(MathHelper.sin(world.getCelestialAngleRadians(par1)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
f4 = afloat[0]; f4 = afloat[0];
f7 = afloat[1]; f7 = afloat[1];
f8 = afloat[2]; f8 = afloat[2];
float f11; float f11;
buffer.begin(6, DefaultVertexFormats.POSITION_COLOR); if (mc.gameSettings.anaglyph) {
f9 = (f4 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
buffer.pos(0d, 100d, 0d).color(f4, f7, f8, afloat[3]).endVertex(); f10 = (f4 * 30.0F + f7 * 70.0F) / 100.0F;
f11 = (f4 * 30.0F + f8 * 70.0F) / 100.0F;
f4 = f9;
f7 = f10;
f8 = f11;
}
buffer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
buffer.color(f4, f7, f8, afloat[3]).pos(0.0, 100D, 0).endVertex();
byte b0 = 16; byte b0 = 16;
for (int j = 0; j <= b0; ++j) { for (int j = 0; j <= b0; ++j) {
f11 = j * (float) Math.PI * 2.0F / b0; f11 = j * (float) Math.PI * 2.0F / b0;
float f12 = MathHelper.sin(f11); float f12 = MathHelper.sin(f11);
float f13 = MathHelper.cos(f11); float f13 = MathHelper.cos(f11);
buffer.color(afloat[0], afloat[1], afloat[2], 0.0F).pos(f12 * 120.0F, f13 * 120.0F, -f13 * 40.0F * afloat[3]).endVertex();
buffer.pos(f12 * 120.0F, f13 * 120.0F, -f13 * 40.0F * afloat[3]).color(afloat[0], afloat[1], afloat[2], 0.0f).endVertex();
} }
tessellator.draw(); tessellator.draw();
GlStateManager.popMatrix(); GL11.glPopMatrix();
GlStateManager.shadeModel(GL11.GL_FLAT); GL11.glShadeModel(GL11.GL_FLAT);
} }
GlStateManager.enableTexture2D(); GL11.glEnable(GL11.GL_TEXTURE_2D);
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GlStateManager.pushMatrix(); GL11.glPushMatrix();
f4 = 1.0F - world.getRainStrength(par1); f4 = 1.0F - world.getRainStrength(par1);
f7 = 0.0F; f7 = 0.0F;
f8 = 0.0F; f8 = 0.0F;
f9 = 0.0F; f9 = 0.0F;
GlStateManager.color(1.0F, 1.0F, 1.0F, f4); GL11.glColor4f(1.0F, 1.0F, 1.0F, f4);
GlStateManager.translate(f7, f8, f9); GL11.glTranslatef(f7, f8, f9);
GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(world.getCelestialAngle(par1) * 360.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(world.getCelestialAngle(par1) * 360.0F, 1.0F, 0.0F, 0.0F);
f10 = 30.0F; f10 = 30.0F;
mc.renderEngine.bindTexture(this.getSunRenderPath()); mc.renderEngine.bindTexture(this.getSunRenderPath());
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
buffer.pos(-f10, 100.0D, -f10).tex(0.0D, 0.0D).endVertex(); buffer.pos(-f10, 100, -f10).tex(0, 0).endVertex();
buffer.pos(f10, 100.0D, -f10).tex(1.0D, 0.0D).endVertex(); buffer.pos(f10, 100, -f10).tex(1, 0).endVertex();
buffer.pos(f10, 100.0D, f10).tex(1.0D, 1.0D).endVertex(); buffer.pos(f10, 100, f10).tex(1, 1).endVertex();
buffer.pos(-f10, 100.0D, f10).tex(0.0D, 1.0D).endVertex(); buffer.pos(-f10, 100, f10).tex(0, 1).endVertex();
tessellator.draw(); tessellator.draw();
f10 = 20.0F; f10 = 20.0F;
@ -137,33 +147,33 @@ public class CustomSkyProvider extends IRenderHandler {
float f16 = l + 1; float f16 = l + 1;
float f17 = i1 + 1; float f17 = i1 + 1;
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
buffer.pos(-f10, -100.0D, f10).tex(f16, f17).endVertex(); buffer.pos(-f10, -100, f10).tex(f16, f17).endVertex();
buffer.pos(f10, -100.0D, f10).tex(f14, f17).endVertex(); buffer.pos(f10, -100, f10).tex(f14, f17).endVertex();
buffer.pos(f10, -100.0D, -f10).tex(f14, f15).endVertex(); buffer.pos(f10, -100, -f10).tex(f14, f15).endVertex();
buffer.pos(-f10, -100.0D, -f10).tex(f16, f15).endVertex(); buffer.pos(-f10, -100, -f10).tex(f16, f15).endVertex();
tessellator.draw(); tessellator.draw();
GlStateManager.disableTexture2D(); GL11.glDisable(GL11.GL_TEXTURE_2D);
float f18 = world.getStarBrightness(par1) * f4; float f18 = world.getStarBrightness(par1) * f4;
if (f18 > 0.0F) { if (f18 > 0.0F) {
GlStateManager.color(f18, f18, f18, f18); GL11.glColor4f(f18, f18, f18, f18);
GlStateManager.callList(this.starGLCallList); GL11.glCallList(this.starGLCallList);
} }
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableBlend(); GL11.glDisable(GL11.GL_BLEND);
GlStateManager.enableAlpha(); GL11.glEnable(GL11.GL_ALPHA_TEST);
GlStateManager.enableFog(); GL11.glEnable(GL11.GL_FOG);
GlStateManager.popMatrix(); GL11.glPopMatrix();
GlStateManager.disableTexture2D(); GL11.glDisable(GL11.GL_TEXTURE_2D);
GlStateManager.color(0.0F, 0.0F, 0.0F); GL11.glColor3f(0.0F, 0.0F, 0.0F);
double d0 = mc.player.getPosition().getY() - world.getHorizon(); double d0 = mc.player.getLook(par1).yCoord - world.getHorizon();
if (d0 < 0.0D) { if (d0 < 0.0D) {
GlStateManager.pushMatrix(); GL11.glPushMatrix();
GlStateManager.translate(0.0F, 12.0F, 0.0F); GL11.glTranslatef(0.0F, 12.0F, 0.0F);
GlStateManager.callList(this.glSkyList2); GL11.glCallList(this.glSkyList2);
GlStateManager.popMatrix(); GL11.glPopMatrix();
f8 = 1.0F; f8 = 1.0F;
f9 = -((float) (d0 + 65.0D)); f9 = -((float) (d0 + 65.0D));
f10 = -f8; f10 = -f8;
@ -193,17 +203,17 @@ public class CustomSkyProvider extends IRenderHandler {
} }
if (world.provider.isSkyColored()) { if (world.provider.isSkyColored()) {
GlStateManager.color(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F); GL11.glColor3f(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F);
} else { } else {
GlStateManager.color(f1, f2, f3); GL11.glColor3f(f1, f2, f3);
} }
GlStateManager.pushMatrix(); GL11.glPushMatrix();
GlStateManager.translate(0.0F, -((float) (d0 - 16.0D)), 0.0F); GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F);
GlStateManager.callList(this.glSkyList2); GL11.glCallList(this.glSkyList2);
GlStateManager.popMatrix(); GL11.glPopMatrix();
GlStateManager.enableTexture2D(); GL11.glEnable(GL11.GL_TEXTURE_2D);
GlStateManager.depthMask(true); GL11.glDepthMask(true);
} }
} }

View file

@ -1,5 +1,6 @@
package com.zixiken.dimdoors.shared.world.limbodimension; package com.zixiken.dimdoors.shared.world.limbodimension;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.world.CustomSkyProvider; import com.zixiken.dimdoors.shared.world.CustomSkyProvider;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -7,14 +8,18 @@ import net.minecraft.util.ResourceLocation;
* Created by Jared Johnson on 1/24/2017. * Created by Jared Johnson on 1/24/2017.
*/ */
public class LimboSkyProvider extends CustomSkyProvider { public class LimboSkyProvider extends CustomSkyProvider {
private static final ResourceLocation limboMoonResourceLoc = new ResourceLocation(DimDoors.MODID + ":textures/other/limboMoon.png");
private static final ResourceLocation limboSunResourceLoc = new ResourceLocation(DimDoors.MODID + ":textures/other/limboSun.png");
@Override @Override
public ResourceLocation getMoonRenderPath() { public ResourceLocation getMoonRenderPath() {
return new ResourceLocation("DimDoors:textures/other/limboMoon.png"); return limboMoonResourceLoc;
} }
@Override @Override
public ResourceLocation getSunRenderPath() { public ResourceLocation getSunRenderPath() {
return new ResourceLocation("DimDoors:textures/other/limboSun.png"); return limboSunResourceLoc;
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB