Re-added biome fog colours and fog density. Closes#251

This commit is contained in:
Adubbz 2016-12-03 18:55:27 +11:00
parent 5791c6dcf2
commit 02b48b2e8b
24 changed files with 497 additions and 170 deletions

View File

@ -27,9 +27,9 @@ public class GuiBOPConfig extends GuiConfig
List<IConfigElement> list = new ArrayList<IConfigElement>();
List<IConfigElement> convenienceSettings = new ConfigElement(GameplayConfigurationHandler.config.getCategory(GameplayConfigurationHandler.convenienceSettings.toLowerCase())).getChildElements();
List<IConfigElement> guiSettings = new ConfigElement(MiscConfigurationHandler.config.getCategory(MiscConfigurationHandler.guiSettings.toLowerCase())).getChildElements();
List<IConfigElement> textureSettings = new ConfigElement(MiscConfigurationHandler.config.getCategory(MiscConfigurationHandler.textureSettings.toLowerCase())).getChildElements();
List<IConfigElement> trailSettings = new ConfigElement(MiscConfigurationHandler.config.getCategory(MiscConfigurationHandler.trailSettings.toLowerCase())).getChildElements();
List<IConfigElement> guiSettings = new ConfigElement(MiscConfigurationHandler.config.getCategory(MiscConfigurationHandler.GUI_SETTINGS.toLowerCase())).getChildElements();
List<IConfigElement> textureSettings = new ConfigElement(MiscConfigurationHandler.config.getCategory(MiscConfigurationHandler.VISUAL_SETTINGS.toLowerCase())).getChildElements();
List<IConfigElement> trailSettings = new ConfigElement(MiscConfigurationHandler.config.getCategory(MiscConfigurationHandler.TRAIL_SETTINGS.toLowerCase())).getChildElements();
list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.category.convenienceSettings.title"), "config.category.convenienceSettings", convenienceSettings));
list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.category.guiSettings.title"), "config.category.guiSettings", guiSettings));

View File

@ -48,6 +48,7 @@ import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Biomes;
import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.ChunkPrimer;
@ -59,7 +60,14 @@ public class BOPBiome extends Biome implements IExtendedBiome
private Map<BOPClimates, Integer> weightMap = new HashMap<BOPClimates, Integer>();
// defaults
public int skyColor = -1; // -1 indicates the default skyColor by temperature will be used
// -1 indicates the defaults as set by Vanilla will be used for the below fields
public int skyColor = -1;
public int fogColor = -1;
/** 1.0 is the lowest possible amount of fog. 0.0 is the greatest.*/
public float fogDensity = 1.0F;
public boolean hasBiomeEssence = true;
public IBlockState seaFloorBlock = Blocks.DIRT.getDefaultState();
@ -147,6 +155,8 @@ public class BOPBiome extends Biome implements IExtendedBiome
this.seaFloorBlock = conf.getBlockState("seaFloorBlock", this.seaFloorBlock);
this.skyColor = conf.getInt("skyColor", this.skyColor);
this.fogColor = conf.getInt("fogColor", this.fogColor);
this.fogDensity = conf.getFloat("fogDensity", this.fogDensity);
this.hasBiomeEssence = conf.getBool("hasBiomeEssence", this.hasBiomeEssence);
this.canSpawnInBiome = conf.getBool("canSpawnInBiome", this.canSpawnInBiome);
@ -310,7 +320,11 @@ public class BOPBiome extends Biome implements IExtendedBiome
{
return this.hasBiomeEssence;
}
public int getFogColor(BlockPos pos) { return this.fogColor; }
public float getFogDensity(BlockPos pos) { return this.fogDensity; }
@Override
public int getSkyColorByTemp(float temperature)
{

View File

@ -56,6 +56,9 @@ public class BiomeGenBambooForest extends BOPBiome
this.terrainSettings.avgHeight(68).heightVariation(5, 10);
this.canGenerateVillages = false;
this.fogColor = 0xCCE874;
this.fogDensity = 0.99F;
this.addWeight(BOPClimates.TROPICAL, 3);
@ -152,16 +155,4 @@ if (!settings.isEnabled(GeneratorType.MUSHROOMS)) {this.removeGenerator("glowshr
double noise = GRASS_COLOR_NOISE.getValue((double)pos.getX() * 0.0225D, (double)pos.getZ() * 0.0225D);
return noise < -0.7D ? 0xD4DB55 : (noise < -0.3D ? 0xBBDD54 : 0xA3E053);
}
// TODO: These 2 are copied from 1.7 - but are they used ever?
public int getFogColour(BlockPos pos)
{
return 0xCCE874;
}
public float getFogDensity(BlockPos pos)
{
return 0.99F;
}
}

View File

@ -60,6 +60,9 @@ public class BiomeGenBayou extends BOPBiome
this.beachBiomeLocation = null;
this.fogColor = 0x90AF95;
this.fogDensity = 0.99F;
this.addWeight(BOPClimates.HOT_SWAMP, 10);
this.spawnableWaterCreatureList.clear();
@ -154,16 +157,4 @@ public class BiomeGenBayou extends BOPBiome
{
return 0x9DDD66;
}
// TODO: These 2 are copied from 1.7 - but are they used ever?
public int getFogColour(BlockPos pos)
{
return 0x90AF95;
}
public float getFogDensity(BlockPos pos)
{
return 0.99F;
}
}

View File

@ -53,7 +53,9 @@ public class BiomeGenColdDesert extends BOPBiome
this.alternateTopBlock = Blocks.SNOW.getDefaultState();
this.canGenerateRivers = false;
this.fogDensity = 0.4F;
this.addWeight(BOPClimates.ICE_CAP, 10);
this.spawnableCreatureList.clear();

View File

@ -30,7 +30,9 @@ public class BiomeGenCrag extends BOPBiome
this.canGenerateRivers = false;
this.beachBiomeLocation = null;
this.fogColor = 0xA06F45;
this.addWeight(BOPClimates.COLD_SWAMP, 1);
this.spawnableCreatureList.clear();

View File

@ -58,7 +58,10 @@ public class BiomeGenDeadSwamp extends BOPBiome
this.canGenerateVillages = false;
this.beachBiomeLocation = null;
this.fogColor = 0x8CAF99;
this.fogDensity = 0.6F;
this.addWeight(BOPClimates.COLD_SWAMP, 3);
this.spawnableCreatureList.clear();
@ -140,22 +143,4 @@ public class BiomeGenDeadSwamp extends BOPBiome
{
return 0x66704C;
}
/* TODO
@Override
public int getFogColour(int x, int y, int z)
{
return 9219993;
}
@Override
public float getFogDensity(int x, int y, int z)
{
// TODO Auto-generated method stub
return 0.6F;
}
*/
}

View File

@ -42,6 +42,9 @@ public class BiomeGenEucalyptusForest extends BOPBiome
this.canGenerateVillages = false;
this.fogColor = 0xE1E8DC;
this.fogDensity = 0.5F;
this.addWeight(BOPClimates.TROPICAL, 5);
this.spawnableMonsterList.add(new SpawnListEntry(EntityOcelot.class, 2, 1, 1));
@ -114,12 +117,4 @@ public class BiomeGenEucalyptusForest extends BOPBiome
GeneratorWeighted grassGen = (GeneratorWeighted)this.getGenerator("grass");
if (!settings.isEnabled(GeneratorType.GRASSES)) {grassGen.removeGenerator("shortgrass"); grassGen.removeGenerator("mediumgrass"); grassGen.removeGenerator("wheatgrass"); grassGen.removeGenerator("dampgrass");}
}
/*
public int getFogColour(int x, int y, int z)
{
return 14805212;
}
*/
}

View File

@ -65,7 +65,9 @@ public class BiomeGenFen extends BOPBiome
{
this.beachBiomeLocation = ((BOPBiome)BOPBiomes.gravel_beach.get()).getResourceLocation();
}
this.fogDensity = 0.8F;
this.addWeight(BOPClimates.COLD_SWAMP, 7);
this.spawnableCreatureList.add(new SpawnListEntry(EntitySnail.class, 8, 1, 2));
@ -175,21 +177,4 @@ public class BiomeGenFen extends BOPBiome
{
return 0xA7C166;
}
/* TODO
@Override
public int getFogColour(int x, int y, int z)
{
return 12638463;
}
@Override
public float getFogDensity(int x, int y, int z)
{
// TODO Auto-generated method stub
return 0.8F;
}
*/
}

View File

@ -53,7 +53,9 @@ public class BiomeGenLandOfLakes extends BOPBiome
this.seaFloorBlock = BOPBlocks.mud.getDefaultState();
this.canGenerateVillages = false;
this.fogDensity = 0.6F;
this.addWeight(BOPClimates.COLD_SWAMP, 3);
if (BOPBiomes.gravel_beach.isPresent())

View File

@ -54,6 +54,8 @@ public class BiomeGenMarsh extends BOPBiome
this.canGenerateVillages = false;
this.beachBiomeLocation = null;
this.fogDensity = 0.6F;
this.addWeight(BOPClimates.WET_TEMPERATE, 7);

View File

@ -59,6 +59,7 @@ public class BiomeGenMysticGrove extends BOPBiome
this.fillerBlock = BOPBlocks.dirt.getDefaultState().withProperty(BlockBOPDirt.VARIANT, BlockBOPDirt.BOPDirtType.SILTY);
this.skyColor = 0x88E8D0;
this.fogColor = 0xFFAAC9;
this.canGenerateRivers = false;
this.canGenerateVillages = false;
@ -194,15 +195,4 @@ public class BiomeGenMysticGrove extends BOPBiome
{
return 0x70E099;
}
// TODO: These 2 are copied from 1.7 - but are they used ever?
public int getFogColour(BlockPos pos)
{
return 0xFFAAC9;
}
public float getFogDensity(BlockPos pos)
{
return 0.99F;
}
}

View File

@ -56,7 +56,10 @@ public class BiomeGenOminousWoods extends BOPBiome
this.canSpawnInBiome = false;
this.beachBiomeLocation = null;
this.fogColor = 0x34333D;
this.fogDensity = 0.145F;
this.addWeight(BOPClimates.COLD_SWAMP, 1);
this.spawnableCreatureList.clear(); // none of your regular farmyard critters here
@ -152,16 +155,4 @@ public class BiomeGenOminousWoods extends BOPBiome
{
return 0x3F4151;
}
// TODO: These 2 are copied from 1.7 - but are they used ever?
public int getFogColour(BlockPos pos)
{
return 0x34333D;
}
public float getFogDensity(BlockPos pos)
{
return 0.145F;
}
}

View File

@ -67,7 +67,10 @@ public class BiomeGenQuagmire extends BOPBiome
this.canGenerateVillages = false;
this.beachBiomeLocation = null;
this.fogColor = 0xCACECD;
this.fogDensity = 0.6F;
this.addWeight(BOPClimates.COLD_SWAMP, 2);
this.spawnableCreatureList.clear();
@ -159,16 +162,4 @@ public class BiomeGenQuagmire extends BOPBiome
{
return 0x9E8B69;
}
// TODO: These 2 are copied from 1.7 - but are they used ever?
public int getFogColour(BlockPos pos)
{
return 0xCACECD;
}
public float getFogDensity(BlockPos pos)
{
return 0.99F;
}
}

View File

@ -35,6 +35,8 @@ public class BiomeGenSeasonalForest extends BOPBiome
// terrain
this.terrainSettings.avgHeight(70).heightVariation(10, 30);
this.fogColor = 0xFFCE84;
this.addWeight(BOPClimates.COOL_TEMPERATE, 7);
this.canGenerateVillages = true;

View File

@ -33,7 +33,6 @@ import net.minecraft.util.math.BlockPos;
public class BiomeGenSnowyForest extends BOPBiome
{
public BiomeGenSnowyForest()
{
super("snowy_forest", new PropsBuilder("Snowy Forest").withGuiColour(0xABD6BC).withSnowEnabled().withTemperature(-0.25F).withRainfall(0.5F));
@ -46,6 +45,9 @@ public class BiomeGenSnowyForest extends BOPBiome
this.canGenerateVillages = false;
this.fogColor = 0xBAC3C6;
this.fogDensity = 0.6F;
this.addWeight(BOPClimates.TUNDRA, 7);
// trees
@ -119,20 +121,4 @@ public class BiomeGenSnowyForest extends BOPBiome
{
return 0xBCA165;
}
/* TODO
@Override
public int getFogColour(int x, int y, int z)
{
return 12239814;
}
@Override
public float getFogDensity(int x, int y, int z)
{
// TODO Auto-generated method stub
return 0.6F;
}
*/
}

View File

@ -45,7 +45,10 @@ public class BiomeGenTemperateRainforest extends BOPBiome
this.terrainSettings.avgHeight(63).heightVariation(10, 35);
this.canGenerateVillages = false;
this.fogColor = 0xD1DBCE;
this.fogDensity = 0.8F;
this.addWeight(BOPClimates.WET_TEMPERATE, 7);
if (BOPBiomes.gravel_beach.isPresent())

View File

@ -41,7 +41,10 @@ public class BiomeGenTropicalRainforest extends BOPBiome
this.canSpawnInBiome = false;
this.canGenerateVillages = false;
this.fogColor = 0xF79F62;
this.fogDensity = 0.99F;
this.addWeight(BOPClimates.TROPICAL, 5);
this.spawnableCreatureList.clear();
@ -148,16 +151,4 @@ public class BiomeGenTropicalRainforest extends BOPBiome
double noise = GRASS_COLOR_NOISE.getValue((double)pos.getX() * 0.0225D, (double)pos.getZ() * 0.0225D);
return noise < -0.1D ? 8970560 : 10870849;
}
// TODO: These 2 are copied from 1.7 - but are they used ever?
public int getFogColour(BlockPos pos)
{
return 0x4AD670;
}
public float getFogDensity(BlockPos pos)
{
return 0.145F;
}
}

View File

@ -50,7 +50,10 @@ public class BiomeGenWasteland extends BOPBiome
this.canSpawnInBiome = false;
this.beachBiomeLocation = null;
this.fogColor = 0xB8BC85;
this.fogDensity = 0.3F;
this.addWeight(BOPClimates.WASTELAND, 50);
this.spawnableCreatureList.clear();
@ -127,16 +130,4 @@ public class BiomeGenWasteland extends BOPBiome
{
return 0x999E55;
}
// TODO: These 2 are copied from 1.7 - but are they used ever?
public int getFogColour(BlockPos pos)
{
return 0xB8BC85;
}
public float getFogDensity(BlockPos pos)
{
return 0.3F;
}
}

View File

@ -61,7 +61,10 @@ public class BiomeGenWetland extends BOPBiome
this.canGenerateVillages = false;
this.beachBiomeLocation = null;
this.fogColor = 0x5E71A0;
this.fogDensity = 0.8F;
this.addWeight(BOPClimates.WET_TEMPERATE, 7);
this.addWeight(BOPClimates.COLD_SWAMP, 5);

View File

@ -24,9 +24,9 @@ public class MiscConfigurationHandler
{
public static Configuration config;
public static String guiSettings = "GUI Settings";
public static String textureSettings = "Texture Settings";
public static String trailSettings = "Trail Settings";
public static final String GUI_SETTINGS = "GUI Settings";
public static final String VISUAL_SETTINGS = "Visual Settings";
public static final String TRAIL_SETTINGS = "Trail Settings";
public static boolean useBoPWorldTypeDefault;
public static boolean overrideTitlePanorama;
@ -34,6 +34,7 @@ public class MiscConfigurationHandler
public static boolean useBoPBucketTexture;
//Client-side only
public static boolean enableFogColours;
public static TrailVisibilityMode trailVisbilityMode;
public static void init(File configFile)
@ -49,19 +50,20 @@ public class MiscConfigurationHandler
{
try
{
//TODO: Make this default to true once all biomes have been implemented
useBoPWorldTypeDefault = config.getBoolean("Default to BoP World Type", guiSettings, false, "Use the Biomes O' Plenty World Type by default when selecting a world.");
overrideTitlePanorama = config.getBoolean("Enable Biomes O\' Plenty Main Menu Panorama", textureSettings, true, "Override the main menu panorama and use ours instead (It\'s nicer!)");
overrideForgeBuckets = config.getBoolean("Enable Biomes O\' Plenty Bucket Textures", textureSettings, true, "Override the Forge bucket texture and use ours instead (It\'s nicer!)");
useBoPBucketTexture = config.getBoolean("Use Biomes O\' Plenty Bucket Textures", textureSettings, false, "Use the Biomes O' Plenty bucket texture (Valid only for BOP fluid.)");
useBoPWorldTypeDefault = config.getBoolean("Default to BoP World Type", GUI_SETTINGS, false, "Use the Biomes O' Plenty World Type by default when selecting a world.");
overrideTitlePanorama = config.getBoolean("Enable Biomes O\' Plenty Main Menu Panorama", VISUAL_SETTINGS, true, "Override the main menu panorama and use ours instead (It\'s nicer!)");
overrideForgeBuckets = config.getBoolean("Enable Biomes O\' Plenty Bucket Textures", VISUAL_SETTINGS, true, "Override the Forge bucket texture and use ours instead (It\'s nicer!)");
useBoPBucketTexture = config.getBoolean("Use Biomes O\' Plenty Bucket Textures", VISUAL_SETTINGS, false, "Use the Biomes O' Plenty bucket texture (Valid only for BOP fluid).");
//Client-side only options
if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
{
enableFogColours = config.getBoolean("Enable Fog Colouration", VISUAL_SETTINGS, true, "Enable fog colouring in some biomes.");
//Check if the player has a trail
if (TrailManager.trailsMap.containsKey(PlayerUtil.getClientPlayerUUID()))
{
trailVisbilityMode = TrailVisibilityMode.values()[config.getInt("Modify Trail Visibility", trailSettings, 0, 0, 1, "0 = All trails visble, 1 = Others can see your trail but you can't")];
trailVisbilityMode = TrailVisibilityMode.values()[config.getInt("Modify Trail Visibility", TRAIL_SETTINGS, 0, 0, 1, "0 = All trails visble, 1 = Others can see your trail but you can't")];
}
}
}

View File

@ -0,0 +1,407 @@
package biomesoplenty.common.handler;
import biomesoplenty.common.biome.overworld.BOPBiome;
import biomesoplenty.common.config.MiscConfigurationHandler;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.common.ForgeModContainer;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.opengl.GL11;
public class FogEventHandler
{
@SubscribeEvent
public void onGetFogColor(EntityViewRenderEvent.FogColors event)
{
if (!MiscConfigurationHandler.enableFogColours) {
return;
}
if (event.getEntity() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer)event.getEntity();
World world = player.world;
int x = MathHelper.floor(player.posX);
int y = MathHelper.floor(player.posY);
int z = MathHelper.floor(player.posZ);
IBlockState stateAtEyes = ActiveRenderInfo.getBlockStateAtEntityViewpoint(world, event.getEntity(), (float)event.getRenderPartialTicks());
if (stateAtEyes.getMaterial() == Material.LAVA)
{
return;
}
Vec3d mixedColor;
if (stateAtEyes.getMaterial() == Material.WATER)
{
mixedColor = getFogBlendColorWater(world, player, x, y, z, event.getRenderPartialTicks());
}
else
{
mixedColor = getFogBlendColour(world, player, x, y, z, event.getRed(), event.getGreen(), event.getBlue(), event.getRenderPartialTicks());
}
event.setRed((float)mixedColor.xCoord);
event.setGreen((float)mixedColor.yCoord);
event.setBlue((float)mixedColor.zCoord);
}
}
private static double fogX, fogZ;
private static boolean fogInit;
private static float fogFarPlaneDistance;
@SubscribeEvent
public void onRenderFog(EntityViewRenderEvent.RenderFogEvent event)
{
Entity entity = event.getEntity();
World world = entity.world;
int playerX = MathHelper.floor(entity.posX);
int playerY = MathHelper.floor(entity.posY);
int playerZ = MathHelper.floor(entity.posZ);
if (playerX == fogX && playerZ == fogZ && fogInit)
{
renderFog(event.getFogMode(), fogFarPlaneDistance, 0.75f);
return;
}
fogInit = true;
int distance = 20;
float fpDistanceBiomeFog = 0F;
float weightBiomeFog = 0;
for (int x = -distance; x <= distance; ++x)
{
for (int z = -distance; z <= distance; ++z)
{
Biome biome = world.getBiome(new BlockPos(playerX + x, 0, playerZ + z));
if (biome instanceof BOPBiome)
{
float distancePart = ((BOPBiome) biome).getFogDensity(new BlockPos(playerX + x, 0, playerZ + z));
float weightPart = 1;
// Check if fog density is enabled for this biome
if (x == -distance)
{
double xDiff = 1 - (entity.posX - playerX);
distancePart *= xDiff;
weightPart *= xDiff;
}
else if (x == distance)
{
double xDiff = (entity.posX - playerX);
distancePart *= xDiff;
weightPart *= xDiff;
}
if (z == -distance)
{
double zDiff = 1 - (entity.posZ - playerZ);
distancePart *= zDiff;
weightPart *= zDiff;
}
else if (z == distance)
{
double zDiff = (entity.posZ - playerZ);
distancePart *= zDiff;
weightPart *= zDiff;
}
fpDistanceBiomeFog += distancePart;
weightBiomeFog += weightPart;
}
}
}
float weightMixed = (distance * 2) * (distance * 2);
float weightDefault = weightMixed - weightBiomeFog;
float fpDistanceBiomeFogAvg = (weightBiomeFog == 0) ? 0 : fpDistanceBiomeFog / weightBiomeFog;
float farPlaneDistance = (fpDistanceBiomeFog * 240 + event.getFarPlaneDistance() * weightDefault) / weightMixed;
float farPlaneDistanceScaleBiome = (0.1f * (1 - fpDistanceBiomeFogAvg) + 0.75f * fpDistanceBiomeFogAvg);
float farPlaneDistanceScale = (farPlaneDistanceScaleBiome * weightBiomeFog + 0.75f * weightDefault) / weightMixed;
fogX = entity.posX;
fogZ = entity.posZ;
fogFarPlaneDistance = Math.min(farPlaneDistance, event.getFarPlaneDistance());
renderFog(event.getFogMode(), fogFarPlaneDistance, farPlaneDistanceScale);
}
private static void renderFog(int fogMode, float farPlaneDistance, float farPlaneDistanceScale)
{
if (fogMode < 0)
{
GL11.glFogf(GL11.GL_FOG_START, 0.0F);
GL11.glFogf(GL11.GL_FOG_END, farPlaneDistance);
}
else
{
GL11.glFogf(GL11.GL_FOG_START, farPlaneDistance * farPlaneDistanceScale);
GL11.glFogf(GL11.GL_FOG_END, farPlaneDistance);
}
}
private static Vec3d postProcessColor(World world, EntityLivingBase player, double r, double g, double b, double renderPartialTicks)
{
double darkScale = (player.lastTickPosY + (player.posY - player.lastTickPosY) * renderPartialTicks) * world.provider.getVoidFogYFactor();
if (player.isPotionActive(MobEffects.BLINDNESS))
{
int duration = player.getActivePotionEffect(MobEffects.BLINDNESS).getDuration();
darkScale *= (duration < 20) ? (1 - duration / 20f) : 0;
}
if (darkScale < 1)
{
darkScale = (darkScale < 0) ? 0 : darkScale * darkScale;
r *= darkScale;
g *= darkScale;
b *= darkScale;
}
if (player.isPotionActive(MobEffects.NIGHT_VISION))
{
// Get night vision brightness, accounting for wavering at end of potion effect
int duration = player.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration();
float brightness = (duration > 200) ? 1 : 0.7f + MathHelper.sin((float)((duration - renderPartialTicks) * Math.PI * 0.2f)) * 0.3f;
// Find scale to bring r, g, or b to 1.0
// Vanilla will actually set the colors to +Infinity if all components are 0, explaining the terrible
// interaction between the blindness and night vision potion effects.
double scale = 1 / r;
scale = Math.min(scale, 1 / g);
scale = Math.min(scale, 1 / b);
r = r * (1 - brightness) + r * scale * brightness;
g = g * (1 - brightness) + g * scale * brightness;
b = b * (1 - brightness) + b * scale * brightness;
}
if (Minecraft.getMinecraft().gameSettings.anaglyph)
{
double aR = (r * 30 + g * 59 + b * 11) / 100;
double aG = (r * 30 + g * 70) / 100;
double aB = (r * 30 + b * 70) / 100;
r = aR;
g = aG;
b = aB;
}
return new Vec3d(r, g, b);
}
private static Vec3d getFogBlendColorWater(World world, EntityLivingBase playerEntity, int playerX, int playerY, int playerZ, double renderPartialTicks)
{
int distance = 2;
float rBiomeFog = 0;
float gBiomeFog = 0;
float bBiomeFog = 0;
for (int x = -distance; x <= distance; ++x)
{
for (int z = -distance; z <= distance; ++z)
{
Biome biome = world.getBiome(new BlockPos(playerX + x, 0, playerZ + z));
int waterColorMult = biome.getWaterColor();
float rPart = (waterColorMult & 0xFF0000) >> 16;
float gPart = (waterColorMult & 0x00FF00) >> 8;
float bPart = waterColorMult & 0x0000FF;
if (x == -distance)
{
double xDiff = 1 - (playerEntity.posX - playerX);
rPart *= xDiff;
gPart *= xDiff;
bPart *= xDiff;
}
else if (x == distance)
{
double xDiff = playerEntity.posX - playerX;
rPart *= xDiff;
gPart *= xDiff;
bPart *= xDiff;
}
if (z == -distance)
{
double zDiff = 1 - (playerEntity.posZ - playerZ);
rPart *= zDiff;
gPart *= zDiff;
bPart *= zDiff;
}
else if (z == distance)
{
double zDiff = playerEntity.posZ - playerZ;
rPart *= zDiff;
gPart *= zDiff;
bPart *= zDiff;
}
rBiomeFog += rPart;
gBiomeFog += gPart;
bBiomeFog += bPart;
}
}
rBiomeFog /= 255f;
gBiomeFog /= 255f;
bBiomeFog /= 255f;
float weight = (distance * 2) * (distance * 2);
float respirationLevel = (float) EnchantmentHelper.getRespirationModifier(playerEntity) * 0.2F;
float rMixed = (rBiomeFog * 0.02f + respirationLevel) / weight;
float gMixed = (gBiomeFog * 0.02f + respirationLevel) / weight;
float bMixed = (bBiomeFog * 0.2f + respirationLevel) / weight;
return postProcessColor(world, playerEntity, rMixed, gMixed, bMixed, renderPartialTicks);
}
private static Vec3d getFogBlendColour(World world, EntityLivingBase playerEntity, int playerX, int playerY, int playerZ, float defR, float defG, float defB, double renderPartialTicks)
{
GameSettings settings = Minecraft.getMinecraft().gameSettings;
int[] ranges = ForgeModContainer.blendRanges;
int distance = 6;
if (settings.fancyGraphics && settings.renderDistanceChunks >= 0 && settings.renderDistanceChunks < ranges.length)
{
distance = ranges[settings.renderDistanceChunks];
}
double rBiomeFog = 0;
double gBiomeFog = 0;
double bBiomeFog = 0;
double weightBiomeFog = 0;
for (int x = -distance; x <= distance; ++x)
{
for (int z = -distance; z <= distance; ++z) {
Biome biome = world.getBiome(new BlockPos(playerX + x, 0, playerZ + z));
if (biome instanceof BOPBiome) {
int fogColour = ((BOPBiome) biome).getFogColor(new BlockPos(playerX + x, 0, playerZ + z));
// Ensure fog colouring is enabled for this biome
if (fogColour >= 0)
{
double rPart = (fogColour & 0xFF0000) >> 16;
double gPart = (fogColour & 0x00FF00) >> 8;
double bPart = fogColour & 0x0000FF;
float weightPart = 1;
if (x == -distance)
{
double xDiff = 1 - (playerEntity.posX - playerX);
rPart *= xDiff;
gPart *= xDiff;
bPart *= xDiff;
weightPart *= xDiff;
} else if (x == distance)
{
double xDiff = playerEntity.posX - playerX;
rPart *= xDiff;
gPart *= xDiff;
bPart *= xDiff;
weightPart *= xDiff;
}
if (z == -distance)
{
double zDiff = 1 - (playerEntity.posZ - playerZ);
rPart *= zDiff;
gPart *= zDiff;
bPart *= zDiff;
weightPart *= zDiff;
} else if (z == distance)
{
double zDiff = playerEntity.posZ - playerZ;
rPart *= zDiff;
gPart *= zDiff;
bPart *= zDiff;
weightPart *= zDiff;
}
rBiomeFog += rPart;
gBiomeFog += gPart;
bBiomeFog += bPart;
weightBiomeFog += weightPart;
}
}
}
}
if (weightBiomeFog == 0 || distance == 0)
{
return new Vec3d(defR, defG, defB);
}
rBiomeFog /= 255f;
gBiomeFog /= 255f;
bBiomeFog /= 255f;
// Calculate day / night / weather scale for BiomeFog component
float celestialAngle = world.getCelestialAngle((float)renderPartialTicks);
float baseScale = MathHelper.clamp(MathHelper.cos(celestialAngle * (float)Math.PI * 2.0F) * 2.0F + 0.5F, 0, 1);
double rScale = baseScale * 0.94F + 0.06F;
double gScale = baseScale * 0.94F + 0.06F;
double bScale = baseScale * 0.91F + 0.09F;
float rainStrength = world.getRainStrength((float)renderPartialTicks);
if (rainStrength > 0) {
rScale *= 1 - rainStrength * 0.5f;
gScale *= 1 - rainStrength * 0.5f;
bScale *= 1 - rainStrength * 0.4f;
}
float thunderStrength = world.getThunderStrength((float)renderPartialTicks);
if (thunderStrength > 0) {
rScale *= 1 - thunderStrength * 0.5f;
gScale *= 1 - thunderStrength * 0.5f;
bScale *= 1 - thunderStrength * 0.5f;
}
// Apply post-processing to BiomeFog component. Default color was already processed by Vanilla.
rBiomeFog *= rScale / weightBiomeFog;
gBiomeFog *= gScale / weightBiomeFog;
bBiomeFog *= bScale / weightBiomeFog;
Vec3d processedColor = postProcessColor(world, playerEntity, rBiomeFog, gBiomeFog, bBiomeFog, renderPartialTicks);
rBiomeFog = processedColor.xCoord;
gBiomeFog = processedColor.yCoord;
bBiomeFog = processedColor.zCoord;
// Mix default fog component with BiomeFog component
double weightMixed = (distance * 2) * (distance * 2);
double weightDefault = weightMixed - weightBiomeFog;
double rFinal = (rBiomeFog * weightBiomeFog + defR * weightDefault) / weightMixed;
double gFinal = (gBiomeFog * weightBiomeFog + defG * weightDefault) / weightMixed;
double bFinal = (bBiomeFog * weightBiomeFog + defB * weightDefault) / weightMixed;
return new Vec3d(rFinal, gFinal, bFinal);
}
}

View File

@ -28,7 +28,7 @@ import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
public class LeavesModelHandler
public class LeavesModelEventHandler
{
private static final ModelResourceLocation LEAVES_LOC = new ModelResourceLocation("biomesoplenty:leaves_3", "variant=flowering");

View File

@ -53,6 +53,7 @@ public class ModHandlers
{
MinecraftForge.EVENT_BUS.register(new GuiEventHandler());
MinecraftForge.EVENT_BUS.register(new TrailsEventHandler());
MinecraftForge.EVENT_BUS.register(new LeavesModelHandler());
MinecraftForge.EVENT_BUS.register(new LeavesModelEventHandler());
MinecraftForge.EVENT_BUS.register(new FogEventHandler());
}
}