Permalink
Browse files

Fixed clouds and storms on Varda.

  • Loading branch information...
Ri5ux committed Dec 17, 2017
1 parent 6b13b14 commit 33196d66246687b598240a2fadb212f0c4abebe2
@@ -0,0 +1,55 @@
package org.avp.world.dimension.varda;
import org.avp.AliensVsPredator;
import com.arisux.mdx.lib.client.render.Texture;
import com.arisux.mdx.lib.client.render.world.ClimateProvider;
import com.arisux.mdx.lib.client.render.world.IStormProvider;
import com.arisux.mdx.lib.game.Game;
import com.arisux.mdx.lib.util.MDXMath;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
public class ClimateProviderVarda extends ClimateProvider
{
public StormProviderVarda stormProvider = new StormProviderVarda();
@Override
public Texture getCloudTexture()
{
return AliensVsPredator.resources().SKY_VARDA_CLOUDS;
}
@Override
public boolean areCloudsApplicableTo(WorldProvider provider)
{
return provider instanceof WorldProviderVarda;
}
@Override
public double getCloudMovementX(World world, float cloudTicksPrev, float cloudTicks)
{
return 0;
}
@Override
public double getCloudMovementZ(World world, float cloudTicksPrev, float cloudTicks)
{
return -MDXMath.interpolateRotation(cloudTicksPrev, cloudTicks, Game.partialTicks());
}
@Override
public void render(float partialTicks, WorldClient world, Minecraft mc)
{
super.render(partialTicks, world, mc);
}
@Override
public IStormProvider getStormProvider()
{
return stormProvider;
}
}
@@ -9,24 +9,20 @@
import com.arisux.mdx.lib.client.render.Color;
import com.arisux.mdx.lib.client.render.Draw;
import com.arisux.mdx.lib.client.render.OpenGL;
import com.arisux.mdx.lib.game.Game;
import com.arisux.mdx.lib.game.GameResources;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.client.IRenderHandler;
public class SkyProviderVarda extends IRenderHandler
{
private Color skyColor = new Color(0.11F, 0.225F, 0.265F, 1F);
protected Color cloudColor = new Color(0.075F, 0.1F, 0.15F, 0.75F);
public int starGLCallList = GLAllocation.generateDisplayLists(3);
public SkyProviderVarda()
@@ -111,11 +107,6 @@ public void render(float partialTicks, WorldClient world, Minecraft mc)
{
WorldProviderVarda provider = (WorldProviderVarda) world.provider;
if (provider.getStormProvider().isStormActive(world))
{
provider.getStormProvider().render(partialTicks);
}
OpenGL.disable(GL11.GL_TEXTURE_2D);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
GL11.glDepthMask(false);
@@ -173,156 +164,6 @@ public void render(float partialTicks, WorldClient world, Minecraft mc)
OpenGL.enable(GL11.GL_ALPHA_TEST);
OpenGL.enable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(true);
if (Game.minecraft().gameSettings.shouldRenderClouds() == 1)
{
OpenGL.pushMatrix();
{
if (Game.minecraft().gameSettings.fancyGraphics)
{
OpenGL.enable(GL11.GL_FOG);
}
this.renderClouds(partialTicks);
OpenGL.disable(GL11.GL_FOG);
}
OpenGL.popMatrix();
}
}
}
public void renderClouds(float renderPartialTicks)
{
for (int cloudPass = 1; cloudPass > 0; cloudPass--)
{
float relativeHeight = (float) (Game.minecraft().getRenderViewEntity().lastTickPosY + (Game.minecraft().getRenderViewEntity().posY - Game.minecraft().getRenderViewEntity().lastTickPosY) * renderPartialTicks);
float cloudSpan = 18.0F;
float cloudHeight = 7.0F * cloudPass;
float cloudSpeed = 10;
double time = Game.minecraft().world.getWorldTime() * cloudSpeed + renderPartialTicks;
double viewX = (Game.minecraft().getRenderViewEntity().prevPosX + (Game.minecraft().getRenderViewEntity().posX - Game.minecraft().getRenderViewEntity().prevPosX) * renderPartialTicks + time * 0.029999999329447746D) / cloudSpan;
double viewZ = (Game.minecraft().getRenderViewEntity().prevPosZ + (Game.minecraft().getRenderViewEntity().posZ - Game.minecraft().getRenderViewEntity().prevPosZ) * renderPartialTicks) / cloudSpan + 0.33000001311302185D;
float cloudY = Game.minecraft().world.provider.getCloudHeight() - relativeHeight;
viewX -= (MathHelper.floor(viewX / 2048.0D)) * 2048;
viewZ -= (MathHelper.floor(viewZ / 2048.0D)) * 2048;
float scaleUV = 0.00390625F;
float offsetU = MathHelper.floor(viewX) * scaleUV;
float offsetV = MathHelper.floor(viewZ) * scaleUV;
byte dist = (byte) (Game.minecraft().gameSettings.renderDistanceChunks);
byte cloudSections = 2;
OpenGL.disableCullFace();
Draw.bindTexture(AliensVsPredator.resources().SKY_VARDA_CLOUDS);
OpenGL.enableBlend();
OpenGlHelper.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
OpenGL.scale(cloudSpan, 1.0F, cloudSpan);
for (int pass = 0; pass < 2; pass++)
{
if (pass == 0)
{
GL11.glColorMask(false, false, false, false);
}
else
{
GL11.glColorMask(true, true, true, true);
}
for (int x = -cloudSections + 1; x <= cloudSections; ++x)
{
for (int z = -cloudSections + 1; z <= cloudSections; ++z)
{
float cloudU = x * dist;
float cloudV = z * dist;
float cloudX = cloudU - ((float) (viewX - MathHelper.floor(viewX)));
float cloudZ = cloudV - ((float) (viewZ - MathHelper.floor(viewZ)));
Draw.startQuads();
if (cloudY > -cloudHeight - 1.0F)
{
Draw.buffer().color(cloudColor.r * 0.7F, cloudColor.g * 0.7F, cloudColor.b * 0.7F, cloudColor.a + 0.1F);
Draw.buffer().normal(0.0F, -1.0F, 0.0F);
Draw.vertex(cloudX + 0.0F, cloudY + 0.0F, cloudZ + dist, (cloudU + 0.0F) * scaleUV + offsetU, (cloudV + dist) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + dist, cloudY + 0.0F, cloudZ + dist, (cloudU + dist) * scaleUV + offsetU, (cloudV + dist) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + dist, cloudY + 0.0F, cloudZ + 0.0F, (cloudU + dist) * scaleUV + offsetU, (cloudV + 0.0F) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + 0.0F, cloudY + 0.0F, cloudZ + 0.0F, (cloudU + 0.0F) * scaleUV + offsetU, (cloudV + 0.0F) * scaleUV + offsetV).endVertex();
}
if (cloudY <= cloudHeight + 1.0F)
{
Draw.buffer().color(cloudColor.r, cloudColor.g, cloudColor.b, cloudColor.a + 0.15F);
Draw.buffer().normal(0.0F, 1.0F, 0.0F);
Draw.vertex(cloudX + 0.0F, cloudY + cloudHeight, cloudZ + dist, (cloudU + 0.0F) * scaleUV + offsetU, (cloudV + dist) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + dist, cloudY + cloudHeight, cloudZ + dist, (cloudU + dist) * scaleUV + offsetU, (cloudV + dist) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + dist, cloudY + cloudHeight, cloudZ + 0.0F, (cloudU + dist) * scaleUV + offsetU, (cloudV + 0.0F) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + 0.0F, cloudY + cloudHeight, cloudZ + 0.0F, (cloudU + 0.0F) * scaleUV + offsetU, (cloudV + 0.0F) * scaleUV + offsetV).endVertex();
}
Draw.buffer().color(cloudColor.r * 0.9F, cloudColor.g * 0.9F, cloudColor.b * 0.9F, cloudColor.a);
if (x > -1)
{
Draw.buffer().normal(-1.0F, 0.0F, 0.0F);
for (int size = 0; size < dist; ++size)
{
Draw.vertex(cloudX + size + 0.0F, cloudY + 0.0F, cloudZ + dist, (cloudU + size + 0.5F) * scaleUV + offsetU, (cloudV + dist) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + size + 0.0F, cloudY + cloudHeight, cloudZ + dist, (cloudU + size + 0.5F) * scaleUV + offsetU, (cloudV + dist) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + size + 0.0F, cloudY + cloudHeight, cloudZ + 0.0F, (cloudU + size + 0.5F) * scaleUV + offsetU, (cloudV + 0.0F) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + size + 0.0F, cloudY + 0.0F, cloudZ + 0.0F, (cloudU + size + 0.5F) * scaleUV + offsetU, (cloudV + 0.0F) * scaleUV + offsetV).endVertex();
}
}
if (x <= 1)
{
Draw.buffer().normal(1.0F, 0.0F, 0.0F);
for (int size = 0; size < dist; ++size)
{
Draw.vertex(cloudX + size + 1.0F, cloudY + 0.0F, cloudZ + dist, (cloudU + size + 0.5F) * scaleUV + offsetU, (cloudV + dist) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + size + 1.0F, cloudY + cloudHeight, cloudZ + dist, (cloudU + size + 0.5F) * scaleUV + offsetU, (cloudV + dist) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + size + 1.0F, cloudY + cloudHeight, cloudZ + 0.0F, (cloudU + size + 0.5F) * scaleUV + offsetU, (cloudV + 0.0F) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + size + 1.0F, cloudY + 0.0F, cloudZ + 0.0F, (cloudU + size + 0.5F) * scaleUV + offsetU, (cloudV + 0.0F) * scaleUV + offsetV).endVertex();
}
}
Draw.buffer().color(cloudColor.r * 0.8F, cloudColor.g * 0.8F, cloudColor.b * 0.8F, 0.8F);
if (z > -1)
{
Draw.buffer().normal(0.0F, 0.0F, -1.0F);
for (int size = 0; size < dist; ++size)
{
Draw.vertex(cloudX + 0.0F, cloudY + cloudHeight, cloudZ + size + 0.0F, (cloudU + 0.0F) * scaleUV + offsetU, (cloudV + size + 0.5F) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + dist, cloudY + cloudHeight, cloudZ + size + 0.0F, (cloudU + dist) * scaleUV + offsetU, (cloudV + size + 0.5F) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + dist, cloudY + 0.0F, cloudZ + size + 0.0F, (cloudU + dist) * scaleUV + offsetU, (cloudV + size + 0.5F) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + 0.0F, cloudY + 0.0F, cloudZ + size + 0.0F, (cloudU + 0.0F) * scaleUV + offsetU, (cloudV + size + 0.5F) * scaleUV + offsetV).endVertex();
}
}
if (z <= 1)
{
Draw.buffer().normal(0.0F, 0.0F, 1.0F);
for (int size = 0; size < dist; ++size)
{
Draw.vertex(cloudX + 0.0F, cloudY + cloudHeight, cloudZ + size + 1.0F, (cloudU + 0.0F) * scaleUV + offsetU, (cloudV + size + 0.5F) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + dist, cloudY + cloudHeight, cloudZ + size + 1.0F, (cloudU + dist) * scaleUV + offsetU, (cloudV + size + 0.5F) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + dist, cloudY + 0.0F, cloudZ + size + 1.0F, (cloudU + dist) * scaleUV + offsetU, (cloudV + size + 0.5F) * scaleUV + offsetV).endVertex();
Draw.vertex(cloudX + 0.0F, cloudY + 0.0F, cloudZ + size + 1.0F, (cloudU + 0.0F) * scaleUV + offsetU, (cloudV + size + 0.5F) * scaleUV + offsetV).endVertex();
}
}
Draw.tessellate();
}
}
}
OpenGL.color(1.0F, 1.0F, 1.0F, 1.0F);
OpenGL.disable(GL11.GL_BLEND);
OpenGL.enable(GL11.GL_CULL_FACE);
}
}
}
Oops, something went wrong.

0 comments on commit 33196d6

Please sign in to comment.