Search in sources :

Example 1 with PlayerEnvAccess

use of net.environmentz.access.PlayerEnvAccess in project EnvironmentZ by Globox1997.

the class TemperatureAspects method coldEnvironment.

public static void coldEnvironment(PlayerEntity playerEntity) {
    if (((PlayerEnvAccess) playerEntity).isColdEnvAffected()) {
        int warmClothingModifier = ColdEffect.warmClothingModifier(playerEntity);
        if (!playerEntity.hasStatusEffect(EffectInit.WARMING) && warmClothingModifier != ConfigInit.CONFIG.warm_armor_tick_modifier * 4 && !ColdEffect.isWarmBlockNearBy(playerEntity)) {
            coldnessTimer++;
            if (playerEntity.hasStatusEffect(EffectInit.WET) && dryingTimer % ConfigInit.CONFIG.wet_bonus_malus == 0) {
                coldnessTimer += 1;
            }
            if (coldnessTimer >= (ConfigInit.CONFIG.cold_tick_interval + warmClothingModifier)) {
                int coldDamageEffectTime = ConfigInit.CONFIG.cold_damage_effect_time;
                if (playerEntity.world.getLevelProperties().isRaining()) {
                    coldDamageEffectTime += ConfigInit.CONFIG.cold_tick_snowing_bonus;
                }
                playerEntity.addStatusEffect(new StatusEffectInstance(EffectInit.COLDNESS, coldDamageEffectTime, 0, false, false, true));
                coldnessTimer = 0;
            }
        } else {
            if (coldnessTimer > 0) {
                coldnessTimer = 0;
            }
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) PlayerEnvAccess(net.environmentz.access.PlayerEnvAccess)

Example 2 with PlayerEnvAccess

use of net.environmentz.access.PlayerEnvAccess 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

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