generated from Turnip-Labs/bta-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
174 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package deus.stanleylib.config; | ||
|
||
import turniplabs.halplibe.util.TomlConfigHandler; | ||
import turniplabs.halplibe.util.toml.Toml; | ||
|
||
import static deus.stanleylib.main.MOD_ID; | ||
|
||
public class ConfigHandler { | ||
|
||
private static final TomlConfigHandler config; | ||
private final TemperatureConfig temperatureConfig; | ||
|
||
public ConfigHandler() { | ||
this.temperatureConfig = new TemperatureConfig(config); | ||
} | ||
|
||
public TemperatureConfig getTemperatureConfig() { | ||
return temperatureConfig; | ||
} | ||
|
||
public TomlConfigHandler getConfig() { | ||
return config; | ||
} | ||
|
||
static { | ||
Toml toml = new Toml("StanleyLibConfig"); | ||
|
||
toml.addCategory("temperatureManagement") | ||
.addEntry("activateTemperatureManagement", true); | ||
|
||
toml.addCategory("weatherEffects") | ||
.addEntry("weatherAffectsTemperature", true) | ||
.addEntry("overworldRain", -0.1F) | ||
.addEntry("overworldSnow", -0.2F) | ||
.addEntry("overworldStorm", -0.1F) | ||
.addEntry("overworldWinterSnow", -0.3F); | ||
|
||
toml.addCategory("itemEffects") | ||
.addEntry("itemAffectsTemperature", true) | ||
.addEntry("torch", 0.8F) | ||
.addEntry("redstoneTorch", 0.5F) | ||
.addEntry("lavaBucket", 0.25F) | ||
.addEntry("netherCoal", 0.25F) | ||
.addEntry("iceCream", -0.05F); | ||
|
||
toml.addCategory("foodEffects") | ||
.addEntry("foodAffectsTemperature", true) | ||
.addEntry("soup", 0.8F) | ||
.addEntry("milk", -0.5F); | ||
|
||
toml.addCategory("lifeEffects") | ||
.addEntry("lifeAffectsTemperature", true) | ||
.addEntry("lowLifePenalization",2) | ||
.addEntry("heightLifeAdvantage",2); | ||
|
||
toml.addCategory("blockEffects") | ||
.addEntry("playerOverBlockAffectsTemperature", true) | ||
.addEntry("snowBlock", -0.05F) | ||
.addEntry("waterBlock", -0.05F) | ||
.addEntry("iceBlock", -0.03F); | ||
|
||
toml.addCategory("snowballEffects") | ||
.addEntry("snowballAffectsTemperature", true) | ||
.addEntry("snowballEffect", 0.01F); | ||
|
||
toml.addCategory("biomeEffects") | ||
.addEntry("biomeAffectsTemperature", true) | ||
.addEntry("plains", 0.0F) | ||
.addEntry("taiga", -0.1F) | ||
.addEntry("nether", 5.0F) | ||
.addEntry("birchForest", 0.0F) | ||
.addEntry("caatinga", -0.01F) | ||
.addEntry("borealForest", 0.0F) | ||
.addEntry("swampLand", -1.0F) | ||
.addEntry("desert", 2.0F) | ||
.addEntry("forest", -0.015F); | ||
|
||
toml.addCategory("leatherProtection") | ||
.addEntry("leatherProtectionPercentage", 0.01F) | ||
.addEntry("leatherProtectsTemperature", true); | ||
|
||
toml.addCategory("seasonEffects") | ||
.addEntry("seasonAffectsTemperature", true) | ||
.addEntry("summerTemperature", 0.04F) | ||
.addEntry("fallTemperature", 0.0F) | ||
.addEntry("winterTemperature", -0.05F) | ||
.addEntry("springTemperature", 0.0F); | ||
|
||
config = new TomlConfigHandler(null, MOD_ID, toml); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
95 changes: 52 additions & 43 deletions
95
src/main/java/deus/stanleylib/config/TemperatureConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,79 @@ | ||
package deus.stanleylib.config; | ||
|
||
import net.minecraft.core.block.material.Material; | ||
import net.minecraft.core.world.biome.*; | ||
import net.minecraft.core.world.season.*; | ||
import net.minecraft.core.world.weather.Weather; | ||
import turniplabs.halplibe.util.TomlConfigHandler; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static deus.stanleylib.main.MOD_CONFIG; | ||
|
||
public class TemperatureConfig { | ||
private Map<Weather, Float> weatherTemperatureAdjustments; | ||
private Map<Material, Float> blockTemperatureAdjustments; | ||
private Map<Class<? extends Season>, Float> seasonAdjustments; | ||
private Map<Class<? extends Biome>, Float> biomeAdjustments; | ||
|
||
public static float LEATHER_ARMOR_PROTECTION = MOD_CONFIG.getFloat("temperature.leather.protection_percentage"); | ||
private final Map<Weather, Double> weatherTemperatureAdjustments; | ||
private final Map<Material, Double> blockTemperatureAdjustments; | ||
private final Map<Class<? extends Season>, Double> seasonAdjustments; | ||
private final Map<Class<? extends Biome>, Double> biomeAdjustments; | ||
|
||
public TemperatureConfig() { | ||
public TemperatureConfig(TomlConfigHandler configHandler) { | ||
weatherTemperatureAdjustments = new HashMap<>(); | ||
blockTemperatureAdjustments = new HashMap<>(); | ||
seasonAdjustments = new HashMap<>(); | ||
biomeAdjustments = new HashMap<>(); | ||
|
||
// Populate maps with values from MOD_CONFIG | ||
weatherTemperatureAdjustments.put(Weather.overworldRain, MOD_CONFIG.getFloat("on_weather.overworldRain")); | ||
weatherTemperatureAdjustments.put(Weather.overworldSnow, MOD_CONFIG.getFloat("on_weather.overworldSnow")); | ||
weatherTemperatureAdjustments.put(Weather.overworldStorm, MOD_CONFIG.getFloat("on_weather.overworldStorm")); | ||
weatherTemperatureAdjustments.put(Weather.overworldWinterSnow, MOD_CONFIG.getFloat("on_weather.overworldWinterSnow")); | ||
|
||
blockTemperatureAdjustments.put(Material.snow, MOD_CONFIG.getFloat("on_player_over.snowBlock")); | ||
blockTemperatureAdjustments.put(Material.water, MOD_CONFIG.getFloat("on_player_over.water")); | ||
blockTemperatureAdjustments.put(Material.ice, MOD_CONFIG.getFloat("on_player_over.iceBlock")); | ||
|
||
seasonAdjustments.put(SeasonSummer.class, MOD_CONFIG.getFloat("temperature.season.summer.value")); | ||
seasonAdjustments.put(SeasonFall.class, MOD_CONFIG.getFloat("temperature.season.fall.value")); | ||
seasonAdjustments.put(SeasonSpring.class, MOD_CONFIG.getFloat("temperature.season.spring.value")); | ||
seasonAdjustments.put(SeasonWinter.class, MOD_CONFIG.getFloat("temperature.season.winter.value")); | ||
|
||
biomeAdjustments.put(BiomeDesert.class, MOD_CONFIG.getFloat("temperature.biome.desert")); | ||
biomeAdjustments.put(BiomeBorealForest.class, MOD_CONFIG.getFloat("temperature.biome.boreal_forest")); | ||
biomeAdjustments.put(BiomeBirchForest.class, MOD_CONFIG.getFloat("temperature.biome.birch_forest")); | ||
biomeAdjustments.put(BiomeCaatinga.class, MOD_CONFIG.getFloat("temperature.biome.caatinga")); | ||
biomeAdjustments.put(BiomePlains.class, MOD_CONFIG.getFloat("temperature.biome.plains")); | ||
biomeAdjustments.put(BiomeSwamp.class, MOD_CONFIG.getFloat("temperature.biome.swanp_land")); | ||
biomeAdjustments.put(BiomeTaiga.class, MOD_CONFIG.getFloat("temperature.biome.Taiga")); | ||
biomeAdjustments.put(BiomeForest.class, MOD_CONFIG.getFloat("temperature.biome.forest")); | ||
biomeAdjustments.put(BiomeNether.class, MOD_CONFIG.getFloat("temperature.biome.nether")); | ||
|
||
// Weather adjustments | ||
if (configHandler.getBoolean("weatherEffects.weatherAffectsTemperature")) { | ||
weatherTemperatureAdjustments.put(Weather.overworldRain, configHandler.getDouble("weatherEffects.overworldRain")); | ||
weatherTemperatureAdjustments.put(Weather.overworldSnow, configHandler.getDouble("weatherEffects.overworldSnow")); | ||
weatherTemperatureAdjustments.put(Weather.overworldStorm, configHandler.getDouble("weatherEffects.overworldStorm")); | ||
weatherTemperatureAdjustments.put(Weather.overworldWinterSnow, configHandler.getDouble("weatherEffects.overworldWinterSnow")); | ||
// Add more weather types if needed | ||
} | ||
|
||
// Block adjustments | ||
if (configHandler.getBoolean("blockEffects.playerOverBlockAffectsTemperature")) { | ||
blockTemperatureAdjustments.put(Material.snow, configHandler.getDouble("blockEffects.snowBlock")); | ||
blockTemperatureAdjustments.put(Material.water, configHandler.getDouble("blockEffects.waterBlock")); | ||
blockTemperatureAdjustments.put(Material.ice, configHandler.getDouble("blockEffects.iceBlock")); | ||
// Add more block materials if needed | ||
} | ||
|
||
// Season adjustments | ||
if (configHandler.getBoolean("seasonEffects.seasonAffectsTemperature")) { | ||
seasonAdjustments.put(SeasonSummer.class, configHandler.getDouble("seasonEffects.summerTemperature")); | ||
seasonAdjustments.put(SeasonFall.class, configHandler.getDouble("seasonEffects.fallTemperature")); | ||
seasonAdjustments.put(SeasonSpring.class, configHandler.getDouble("seasonEffects.springTemperature")); | ||
seasonAdjustments.put(SeasonWinter.class, configHandler.getDouble("seasonEffects.winterTemperature")); | ||
} | ||
|
||
// Biome adjustments | ||
if (configHandler.getBoolean("biomeEffects.biomeAffectsTemperature")) { | ||
biomeAdjustments.put(BiomeDesert.class, configHandler.getDouble("biomeEffects.desert")); | ||
biomeAdjustments.put(BiomeBorealForest.class, configHandler.getDouble("biomeEffects.borealForest")); | ||
biomeAdjustments.put(BiomeBirchForest.class, configHandler.getDouble("biomeEffects.birchForest")); | ||
biomeAdjustments.put(BiomeCaatinga.class, configHandler.getDouble("biomeEffects.caatinga")); | ||
biomeAdjustments.put(BiomePlains.class, configHandler.getDouble("biomeEffects.plains")); | ||
biomeAdjustments.put(BiomeSwamp.class, configHandler.getDouble("biomeEffects.swampLand")); | ||
biomeAdjustments.put(BiomeTaiga.class, configHandler.getDouble("biomeEffects.taiga")); | ||
biomeAdjustments.put(BiomeForest.class, configHandler.getDouble("biomeEffects.forest")); | ||
biomeAdjustments.put(BiomeNether.class, configHandler.getDouble("biomeEffects.nether")); | ||
} | ||
} | ||
|
||
public float getWeatherTemperatureAdjustment(Weather weather) { | ||
return weatherTemperatureAdjustments.getOrDefault(weather, 0.0F); | ||
public Double getWeatherTemperatureAdjustment(Weather weather) { | ||
return weatherTemperatureAdjustments.getOrDefault(weather, 0.0); | ||
} | ||
|
||
public float getBlockTemperatureAdjustment(Material material) { | ||
return blockTemperatureAdjustments.getOrDefault(material, 0.0F); | ||
public Double getBlockTemperatureAdjustment(Material material) { | ||
return blockTemperatureAdjustments.getOrDefault(material, 0.0); | ||
} | ||
|
||
public float getSeasonAdjustment(Season season) { | ||
return seasonAdjustments.getOrDefault(season.getClass(), 0.0F); | ||
public Double getSeasonAdjustment(Season season) { | ||
return seasonAdjustments.getOrDefault(season.getClass(), 0.0); | ||
} | ||
|
||
public float getBiomeAdjustment(Biome biome) { | ||
return biomeAdjustments.getOrDefault(biome.getClass(), 0.0F); | ||
|
||
public Double getBiomeAdjustment(Biome biome) { | ||
return biomeAdjustments.getOrDefault(biome.getClass(), 0.0); | ||
} | ||
|
||
} |
Oops, something went wrong.