Modding: Dimension Changing fog color

In this tutorial I will show you how to give your dimension a custom fog color. This is done in the WorldProvider file. I will start with this file.


package Tutorial.common;

import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.ChunkCoordinates;
import net.minecraft.src.IChunkProvider;
import net.minecraft.src.World;
import net.minecraft.src.WorldChunkManagerHell;
import net.minecraft.src.WorldProviderBase;

public class WorldProviderTutorial extends WorldProviderBase 
{
public int getDimensionID() 
{
return 37;
}

public void registerWorldChunkManager()
    {
        worldChunkMgr = new WorldChunkManagerHell(BiomeGenBase.extremeHills, 0.8F, 0.1F);
    }

    public IChunkProvider getChunkProvider()
    {
        return new ChunkProviderTutorial(worldObj, worldObj.getSeed(), true);
    }
    
public boolean canRespawnHere()
    {
        return true;
    }

public String func_80007_l() 
{
return null;
}
}


This is the code used to get the fog color.


@SideOnly(Side.CLIENT)
public Vec3 getFogColor(float par1, float par2)
    {
        float var3 = MathHelper.cos(par1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F;

        if (var3 < 0.0F)
        {
            var3 = 0.0F;
        }

        if (var3 > 1.0F)
        {
            var3 = 1.0F;
        }

        float var4 = 0.7529412F;
        float var5 = 0.84705883F;
        float var6 = 1.0F;
        var4 *= var3 * 3.94F + 0.06F;
        var5 *= var3 * 0.94F + 0.06F;
        var6 *= var3 * 0.91F + 0.09F;
        return Vec3.getVec3Pool().getVecFromPool((double)var4, (double)var5, (double)var6);
    }


If you want the dimension to have the normal fog colors you don’t need this method, but if you want it to be different just change the lines starting with var4, var5 and var 6. They are the RGB values of the fog color.
This is what the file should look like.


package Tutorial.common;

import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.ChunkCoordinates;
import net.minecraft.src.IChunkProvider;
import net.minecraft.src.World;
import net.minecraft.src.WorldChunkManagerHell;
import net.minecraft.src.WorldProviderBase;

public class WorldProviderTutorial extends WorldProviderBase 
{
public int getDimensionID() 
{
return 37;
}

public void registerWorldChunkManager()
    {
        worldChunkMgr = new WorldChunkManagerHell(BiomeGenBase.extremeHills, 0.8F, 0.1F);
    }

    public IChunkProvider getChunkProvider()
    {
        return new ChunkProviderTutorial(worldObj, worldObj.getSeed(), true);
    }

    @SideOnly(Side.CLIENT)
   public Vec3 getFogColor(float par1, float par2)
    {
        float var3 = MathHelper.cos(par1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F;

        if (var3 < 0.0F)
        {
            var3 = 0.0F;
        }

        if (var3 > 1.0F)
        {
            var3 = 1.0F;
        }

        float var4 = 0.7529412F;
        float var5 = 0.84705883F;
        float var6 = 1.0F;
        var4 *= var3 * 3.94F + 0.06F;
        var5 *= var3 * 0.94F + 0.06F;
        var6 *= var3 * 0.91F + 0.09F;
        return Vec3.getVec3Pool().getVecFromPool((double)var4, (double)var5, (double)var6);
    }
    
public boolean canRespawnHere()
    {
        return true;
    }

public String func_80007_l() 
{
return null;
}
}


In this case the fog is pink, but you could make it any color you want.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">