Skip to content

Commit

Permalink
1.3.140 - full control over biome temperatures
Browse files Browse the repository at this point in the history
  • Loading branch information
kotmatross28729 committed Jul 4, 2024
1 parent 4c3d98b commit d07ca3b
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 58 deletions.
13 changes: 0 additions & 13 deletions src/main/java/enviromine/core/EM_ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,6 @@ private static void loadGlobalConfig(File file)
EM_Settings.HydrogenSulfideSeverePoisoningLevel = config.getInt("Hydrogen Sulfide Severe Poisoning Level",Configuration.CATEGORY_GENERAL, 1, 0, 65536, "What level of poisoning applies when player is severe Hydrogen Sulfide poisoned?");
EM_Settings.HydrogenSulfidePoisoningChance = config.getInt("Chance of Hydrogen Sulfide Poisoning",Configuration.CATEGORY_GENERAL, 5, 1, 65536, "What is the chance of Hydrogen Sulfide poisoning if the player has no protection?");

EM_Settings.biomeTemperatureRainBool = config.getBoolean("Biome temperature should rain change", Configuration.CATEGORY_GENERAL, true, "Should the biome temperature decreases if it rains?");
EM_Settings.biomeTemperatureRain = config.getFloat("Biome temperature rain change",Configuration.CATEGORY_GENERAL, 10F, 1F, 65536F, "Biome temperature decreases by n degrees if it rains");

EM_Settings.biomeTemperatureThunderBool = config.getBoolean("Biome temperature should thunder change", Configuration.CATEGORY_GENERAL, true, "Should the biome temperature decreases if there is a thunderstorm?");
EM_Settings.biomeTemperatureThunder = config.getFloat("Biome temperature thunder change",Configuration.CATEGORY_GENERAL, 12F, 1F, 65536F, "Biome temperature decreases by n degrees if there is a thunderstorm");

EM_Settings.biome_DAY_TEMPERATURE = config.getFloat("Absolute maximum of the day",Configuration.CATEGORY_GENERAL, 0F, -128F, 65536F, "temperatureChange will be equal to this number at exactly noon. Read more about this setting in changelog 1.3.139");
EM_Settings.biome_NIGHT_TEMPERATURE = config.getFloat("Absolute maximum of the night",Configuration.CATEGORY_GENERAL, 8F, -128F, 65536F, "temperatureChange will be equal to this number at exactly midnight. Read more about this setting in changelog 1.3.139");

EM_Settings.biome_DAWN_TEMPERATURE = config.getFloat("Absolute dawn",Configuration.CATEGORY_GENERAL, 4F, -128F, 65536F, "temperatureChange will be equal to this number at exactly dawn");
EM_Settings.biome_DUSK_TEMPERATURE = config.getFloat("Absolute dusk",Configuration.CATEGORY_GENERAL, 4F, -128F, 65536F, "temperatureChange will be equal to this number at exactly dusk");


EM_Settings.versionChecker = config.getBoolean("Version Checker", Configuration.CATEGORY_GENERAL, false, "Displays a client-side chat message on login if there's an update available.");
EM_Settings.loggerVerbosity = config.getInt("Logger Verbosity", Configuration.CATEGORY_GENERAL, 2, 0, 3, "Amount of messaging to dump to the console."
+ "\n0: No log messages are printed whatsoever"
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/enviromine/core/EM_Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,6 @@ public class EM_Settings
public static int HydrogenSulfidePoisoningChance;
//HydrogenSulfide

public static boolean biomeTemperatureRainBool;
public static float biomeTemperatureRain;

public static boolean biomeTemperatureThunderBool;
public static float biomeTemperatureThunder;

public static float biome_DAY_TEMPERATURE;
public static float biome_NIGHT_TEMPERATURE;
public static float biome_DAWN_TEMPERATURE;
public static float biome_DUSK_TEMPERATURE;

public static boolean hardcoregases = false;

public static boolean enablePhysics = false;
Expand Down
85 changes: 60 additions & 25 deletions src/main/java/enviromine/handlers/EM_StatusManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,38 @@ public static float[] getSurroundingData(EntityLivingBase entityLiving, int cube
if (dimensionProp != null && dimensionProp.override && !dimensionProp.weatherAffectsTemp) {

} else {
if (entityLiving.worldObj.isRaining() && biome.rainfall != 0.0F && EM_Settings.biomeTemperatureRainBool) {
biomeTemperature -= EM_Settings.biomeTemperatureRain;
float biomeTemperatureRain = 6F;
float biomeTemperatureThunder = 8F;
float biomeTemperatureShade = 2.5F;

boolean biomeTemperatureRainBool = false;
boolean biomeTemperatureThunderBool = false;

if (biome != null) {
BiomeProperties biomeOverride = null;
if (BiomeProperties.base.hasProperty(biome)) {
biomeOverride = BiomeProperties.base.getProperty(biome);
}
if (biomeOverride != null && biomeOverride.biomeOveride) {
biomeTemperatureRain = biomeOverride.TemperatureRainDecrease;
biomeTemperatureThunder = biomeOverride.TemperatureThunderDecrease;
biomeTemperatureRainBool = biomeOverride.TemperatureRainBool;
biomeTemperatureThunderBool = biomeOverride.TemperatureThunderBool;
biomeTemperatureShade = biomeOverride.TemperatureShadeDecrease;
}
}

if (entityLiving.worldObj.isRaining() && biome.rainfall != 0.0F && biomeTemperatureRainBool) {
biomeTemperature -= biomeTemperatureRain;
animalHostility = -1;

if (entityLiving.worldObj.canBlockSeeTheSky(i, j, k)) {
dropSpeed = 0.01F;
}
} else if (entityLiving.worldObj.isThundering() && biome.rainfall != 0.0F && EM_Settings.biomeTemperatureThunderBool) {
biomeTemperature -= EM_Settings.biomeTemperatureThunder;
} else if (entityLiving.worldObj.isThundering() && biome.rainfall != 0.0F && biomeTemperatureThunderBool) {


biomeTemperature -= biomeTemperatureThunder;
animalHostility = -1;

if (entityLiving.worldObj.canBlockSeeTheSky(i, j, k)) {
Expand All @@ -454,9 +477,18 @@ public static float[] getSurroundingData(EntityLivingBase entityLiving, int cube

} // Dimension Overrides End

float biomeTemperatureShade = 2.5F;
if (biome != null) {
BiomeProperties biomeOverride = null;
if (BiomeProperties.base.hasProperty(biome)) {
biomeOverride = BiomeProperties.base.getProperty(biome);
} if (biomeOverride != null && biomeOverride.biomeOveride) {
biomeTemperatureShade = biomeOverride.TemperatureShadeDecrease;
}
}
// Shade
if (!entityLiving.worldObj.canBlockSeeTheSky(i, j, k) && isDay && !entityLiving.worldObj.isRaining()) {
biomeTemperature -= 2.5F;
biomeTemperature -= biomeTemperatureShade;
}

if ((!entityLiving.worldObj.provider.hasNoSky && dimensionProp == null) || (dimensionProp != null && dimensionProp.override && dimensionProp.dayNightTemp)) {
Expand All @@ -473,23 +505,14 @@ public static float[] getSurroundingData(EntityLivingBase entityLiving, int cube
//| 18000 - 23000 |After midnight |
//| 23000 - 24000 (0) |Dawn |




//LogManager.getLogger().fatal("biomeTemperature old " + biomeTemperature);


float currentTime = (entityLiving.worldObj.getWorldTime() % 24000L);
//LogManager.getLogger().fatal("currentTime " + currentTime);

float temperatureChange = calculateTemperatureChange(currentTime);
//LogManager.getLogger().fatal("temperatureChange " + temperatureChange);

biomeTemperature -= temperatureChange;

boolean isDesertBiome = false;
float DesertBiomeTemperatureMultiplier = 1F;

float biome_DAWN_TEMPERATURE = 4F;
float biome_DAY_TEMPERATURE = 0F;
float biome_DUSK_TEMPERATURE = 4F;
float biome_NIGHT_TEMPERATURE = 8F;

if (biome != null) {
BiomeProperties biomeOverride = null;
if (BiomeProperties.base.hasProperty(biome)) {
Expand All @@ -499,13 +522,25 @@ public static float[] getSurroundingData(EntityLivingBase entityLiving, int cube

isDesertBiome = biomeOverride.isDesertBiome;
DesertBiomeTemperatureMultiplier = biomeOverride.DesertBiomeTemperatureMultiplier;

biome_DAWN_TEMPERATURE = biomeOverride.DAWN_TEMPERATURE;
biome_DAY_TEMPERATURE = biomeOverride.DAY_TEMPERATURE;
biome_DUSK_TEMPERATURE = biomeOverride.DUSK_TEMPERATURE;
biome_NIGHT_TEMPERATURE = biomeOverride.NIGHT_TEMPERATURE;
}
}

float currentTime = (entityLiving.worldObj.getWorldTime() % 24000L);
//LogManager.getLogger().fatal("currentTime " + currentTime);

float temperatureChange = calculateTemperatureChange(currentTime, biome_DAWN_TEMPERATURE, biome_DAY_TEMPERATURE, biome_DUSK_TEMPERATURE, biome_NIGHT_TEMPERATURE);
//LogManager.getLogger().fatal("temperatureChange " + temperatureChange);

biomeTemperature -= temperatureChange;

if (biome.rainfall <= 0F || isDesertBiome) {
biomeTemperature -= temperatureChange * DesertBiomeTemperatureMultiplier;
}
//LogManager.getLogger().fatal("biomeTemperature new " + biomeTemperature);
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -1041,14 +1076,14 @@ else if (!entityLiving.isPotionActive(Potion.fireResistance)) {
//public static final float NIGHT_TEMPERATURE = EM_Settings.biome_NIGHT_TEMPERATURE; //Will be at midnight, this/2 at dawn|dusk, also affects at the function increase | maximum function value

//Time const
public static final float DAY_TEMPERATURE = EM_Settings.biome_DAY_TEMPERATURE; // Will be at noon
public static final float NIGHT_TEMPERATURE = EM_Settings.biome_NIGHT_TEMPERATURE; // Will be at midnight
public static final float DAWN_TEMPERATURE = EM_Settings.biome_DAWN_TEMPERATURE; // Will be at dawn
public static final float DUSK_TEMPERATURE = EM_Settings.biome_DUSK_TEMPERATURE; // Will be at dusk
// public static final float DAY_TEMPERATURE = EM_Settings.biome_DAY_TEMPERATURE; // Will be at noon
// public static final float NIGHT_TEMPERATURE = EM_Settings.biome_NIGHT_TEMPERATURE; // Will be at midnight
// public static final float DAWN_TEMPERATURE = EM_Settings.biome_DAWN_TEMPERATURE; // Will be at dawn
// public static final float DUSK_TEMPERATURE = EM_Settings.biome_DUSK_TEMPERATURE; // Will be at dusk


// Function to calculate temperature change
public static float calculateTemperatureChange(float currentTime/*, float DAY_TEMPERATURE, float NIGHT_TEMPERATURE,float DAWN_TEMPERATURE, float DUSK_TEMPERATURE*/) {
public static float calculateTemperatureChange(float currentTime, float DAWN_TEMPERATURE, float DAY_TEMPERATURE, float DUSK_TEMPERATURE, float NIGHT_TEMPERATURE) {
float temperatureChange;

// from 0 to 6000 ticks (dawn to noon)
Expand Down
Loading

0 comments on commit d07ca3b

Please sign in to comment.