Search in sources :

Example 1 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance 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 StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance 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 3 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance 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)

Example 4 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.

the class TotemEntity method applyEffects.

private void applyEffects() {
    if (!this.world.isClient()) {
        Box axisalignedbb = (new Box(this.pos)).expand(40).stretch(0.0D, (double) this.world.getHeight(), 0.0D);
        List<DemonEntity> list = this.world.getNonSpectatingEntities(DemonEntity.class, axisalignedbb);
        for (DemonEntity entity : list) {
            entity.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 1000, 1));
            entity.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 1000, 1));
            entity.setGlowing(true);
        }
    }
}
Also used : DemonEntity(mod.azure.doom.entity.DemonEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) Box(net.minecraft.util.math.Box)

Example 5 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.

the class IconofsinEntity method tickMovement.

@Override
public void tickMovement() {
    super.tickMovement();
    ++this.age;
    if (!this.world.isClient) {
        if (this.getHealth() >= (this.getMaxHealth() * 0.50)) {
            this.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 1000000, 1));
        } else {
            this.removeStatusEffect(StatusEffects.STRENGTH);
            this.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 10000000, 2));
            this.addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 10000000, 1));
        }
        if (!this.world.getDimension().isRespawnAnchorWorking()) {
            this.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 10000000, 3));
            if (this.age % 2400 == 0) {
                this.heal(40F);
            }
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Aggregations

StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)99 LivingEntity (net.minecraft.entity.LivingEntity)14 StatusEffect (net.minecraft.entity.effect.StatusEffect)14 ItemStack (net.minecraft.item.ItemStack)14 PlayerEntity (net.minecraft.entity.player.PlayerEntity)13 Inject (org.spongepowered.asm.mixin.injection.Inject)12 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)8 List (java.util.List)3 Sprite (net.minecraft.client.texture.Sprite)3 StatusEffectSpriteManager (net.minecraft.client.texture.StatusEffectSpriteManager)3 Entity (net.minecraft.entity.Entity)3 Box (net.minecraft.util.math.Box)3 ArrayList (java.util.ArrayList)2 EventHandler (mathax.client.eventbus.EventHandler)2 StatusEffectInstanceAccessor (mathax.client.mixin.StatusEffectInstanceAccessor)2 StatusEffectInstanceAccessor (meteordevelopment.meteorclient.mixin.StatusEffectInstanceAccessor)2 ThirstManager (net.dehydration.thirst.ThirstManager)2 PlayerEnvAccess (net.environmentz.access.PlayerEnvAccess)2 TextRenderer (net.minecraft.client.font.TextRenderer)2 InGameHud (net.minecraft.client.gui.hud.InGameHud)2