Search in sources :

Example 1 with ThirstManager

use of net.dehydration.thirst.ThirstManager in project EnvironmentZ by Globox1997.

the class TemperatureAspects method acclimatize.

public static void acclimatize(PlayerEntity playerEntity) {
    if (playerEntity.hasStatusEffect(EffectInit.COLDNESS)) {
        if (ColdEffect.isWarmBlockNearBy(playerEntity) || playerEntity.world.getBiome(playerEntity.getBlockPos()).getTemperature() >= ConfigInit.CONFIG.acclimatize_biome_temp || playerEntity.hasStatusEffect(EffectInit.WARMING)) {
            acclimatizeTimer++;
            if (acclimatizeTimer >= ConfigInit.CONFIG.heating_up_interval) {
                int coldDuration = playerEntity.getStatusEffect(EffectInit.COLDNESS).getDuration();
                playerEntity.removeStatusEffect(EffectInit.COLDNESS);
                if (coldDuration > ConfigInit.CONFIG.heating_up_cold_tick_decrease) {
                    playerEntity.addStatusEffect(new StatusEffectInstance(EffectInit.COLDNESS, coldDuration - ConfigInit.CONFIG.heating_up_cold_tick_decrease, 0, false, false, true));
                }
                acclimatizeTimer = 0;
            }
        } else if (acclimatizeTimer > 0) {
            acclimatizeTimer = 0;
        }
    } else if (playerEntity.hasStatusEffect(EffectInit.OVERHEATING)) {
        if (playerEntity.world.isNight() || playerEntity.world.getBiome(playerEntity.getBlockPos()).getTemperature() <= ConfigInit.CONFIG.acclimatize_biome_temp || playerEntity.isTouchingWaterOrRain() || playerEntity.hasStatusEffect(EffectInit.COOLING)) {
            acclimatizeTimer++;
            if (FabricLoader.getInstance().isModLoaded("dehydration")) {
                ThirstManager thirstManager = ((ThirstManagerAccess) playerEntity).getThirstManager(playerEntity);
                if (thirstManager.getThirstLevel() > 17) {
                    if (acclimatizeTimer >= ConfigInit.CONFIG.cooling_down_interval) {
                        int coldDuration = playerEntity.getStatusEffect(EffectInit.OVERHEATING).getDuration();
                        playerEntity.removeStatusEffect(EffectInit.OVERHEATING);
                        if (coldDuration > ConfigInit.CONFIG.cooling_down_tick_decrease) {
                            playerEntity.addStatusEffect(new StatusEffectInstance(EffectInit.OVERHEATING, coldDuration - ConfigInit.CONFIG.cooling_down_tick_decrease, 0, false, false, true));
                            thirstManager.addDehydration(ConfigInit.CONFIG.overheating_dehydration_thirst);
                        }
                        acclimatizeTimer = 0;
                    }
                }
            } else {
                if (acclimatizeTimer >= ConfigInit.CONFIG.cooling_down_interval) {
                    int coldDuration = playerEntity.getStatusEffect(EffectInit.OVERHEATING).getDuration();
                    playerEntity.removeStatusEffect(EffectInit.OVERHEATING);
                    if (coldDuration > ConfigInit.CONFIG.cooling_down_tick_decrease) {
                        playerEntity.addStatusEffect(new StatusEffectInstance(EffectInit.OVERHEATING, coldDuration - ConfigInit.CONFIG.cooling_down_tick_decrease, 0, false, false, true));
                    }
                    acclimatizeTimer = 0;
                }
            }
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ThirstManager(net.dehydration.thirst.ThirstManager)

Example 2 with ThirstManager

use of net.dehydration.thirst.ThirstManager in project EnvironmentZ by Globox1997.

the class TemperatureAspects method hotEnvironment.

public static void hotEnvironment(PlayerEntity playerEntity) {
    if (((PlayerEnvAccess) playerEntity).isHotEnvAffected()) {
        if (!playerEntity.hasStatusEffect(EffectInit.COOLING) && OverheatingEffect.wearsArmor(playerEntity) && !playerEntity.isTouchingWaterOrRain() && playerEntity.world.isSkyVisible(playerEntity.getBlockPos()) && playerEntity.world.isDay()) {
            dehydrationTimer++;
            if (FabricLoader.getInstance().isModLoaded("dehydration")) {
                if (dehydrationTimer % ConfigInit.CONFIG.overheating_dehydration_timer == 0) {
                    ThirstManager thirstManager = ((ThirstManagerAccess) playerEntity).getThirstManager(playerEntity);
                    thirstManager.addDehydration(ConfigInit.CONFIG.overheating_dehydration_thirst);
                }
            }
            if (playerEntity.hasStatusEffect(EffectInit.WET) && dehydrationTimer % ConfigInit.CONFIG.wet_bonus_malus == 0) {
                dehydrationTimer -= 1;
            }
            if (dehydrationTimer >= (ConfigInit.CONFIG.overheating_tick_interval)) {
                if (FabricLoader.getInstance().isModLoaded("dehydration")) {
                    ThirstManager thirstManager = ((ThirstManagerAccess) playerEntity).getThirstManager(playerEntity);
                    if (thirstManager.getThirstLevel() < 14) {
                        playerEntity.addStatusEffect(new StatusEffectInstance(EffectInit.OVERHEATING, ConfigInit.CONFIG.overheating_damage_effect_time, 0, false, false, true));
                    }
                } else {
                    playerEntity.addStatusEffect(new StatusEffectInstance(EffectInit.OVERHEATING, ConfigInit.CONFIG.overheating_damage_effect_time, 0, false, false, true));
                }
                dehydrationTimer = 0;
            }
        } else if (dehydrationTimer > 0) {
            dehydrationTimer = 0;
        }
    }
}
Also used : ThirstManagerAccess(net.dehydration.access.ThirstManagerAccess) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) PlayerEnvAccess(net.environmentz.access.PlayerEnvAccess) ThirstManager(net.dehydration.thirst.ThirstManager)

Aggregations

ThirstManager (net.dehydration.thirst.ThirstManager)2 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)2 ThirstManagerAccess (net.dehydration.access.ThirstManagerAccess)1 PlayerEnvAccess (net.environmentz.access.PlayerEnvAccess)1