Search in sources :

Example 11 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.

the class TheftStatusEffect method applyUpdateEffect.

@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
    if (!entity.world.isClient && entity.age % 20 == 0) {
        entity.world.getEntitiesByClass(LivingEntity.class, entity.getBoundingBox().expand(3 * (amplifier + 1)), foundEntity -> foundEntity != entity).forEach(livingEntity -> {
            List<StatusEffectInstance> statusEffects = livingEntity.getStatusEffects().stream().filter(instance -> instance.getEffectType().getCategory() == StatusEffectCategory.BENEFICIAL && !instance.isAmbient()).toList();
            for (StatusEffectInstance statusEffect : statusEffects) {
                entity.addStatusEffect(new StatusEffectInstance(statusEffect.getEffectType(), statusEffect.getDuration() / 2, statusEffect.getAmplifier()));
                livingEntity.removeStatusEffect(statusEffect.getEffectType());
            }
        });
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) StatusEffectCategory(net.minecraft.entity.effect.StatusEffectCategory) StatusEffect(net.minecraft.entity.effect.StatusEffect) List(java.util.List) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) BWStatusEffects(moriyashiine.bewitchment.common.registry.BWStatusEffects) LivingEntity(net.minecraft.entity.LivingEntity) AttributeContainer(net.minecraft.entity.attribute.AttributeContainer) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 12 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.

the class CorruptionStatusEffect method applyUpdateEffect.

@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
    if (!entity.world.isClient) {
        Registry.STATUS_EFFECT.stream().forEach(effect -> {
            if (effect.getCategory() == StatusEffectCategory.BENEFICIAL && entity.hasStatusEffect(effect) && !entity.getStatusEffect(effect).isAmbient()) {
                StatusEffect inverse = INVERSE_EFFECTS.get(effect);
                StatusEffectInstance inverseEffect = null;
                if (inverse != null) {
                    StatusEffectInstance goodEffect = entity.getStatusEffect(effect);
                    inverseEffect = new StatusEffectInstance(inverse, goodEffect.getDuration(), goodEffect.getAmplifier(), goodEffect.isAmbient(), goodEffect.shouldShowParticles(), goodEffect.shouldShowIcon());
                }
                entity.removeStatusEffect(effect);
                if (inverseEffect != null) {
                    entity.addStatusEffect(inverseEffect);
                }
            }
        });
    }
}
Also used : StatusEffect(net.minecraft.entity.effect.StatusEffect) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 13 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.

the class LeonardEntity method tick.

@Override
public void tick() {
    super.tick();
    if (!world.isClient) {
        bossBar.setPercent(getHealth() / getMaxHealth());
        LivingEntity target = getTarget();
        int timer = age + getId();
        if (timer % 300 == 0 && getHealth() < getMaxHealth() && (target == null || distanceTo(target) < 4)) {
            spawnPotion(getBlockPos(), Potions.AWKWARD);
            addStatusEffect(new StatusEffectInstance(StatusEffects.INSTANT_HEALTH, 1, 1));
        }
        if (target != null) {
            timeSinceLastAttack++;
            if (timeSinceLastAttack >= 600) {
                BWUtil.teleport(this, target.getX(), target.getY(), target.getZ(), true);
                timeSinceLastAttack = 0;
            }
            lookAtEntity(target, 360, 360);
            if (timer % 40 == 0) {
                spawnPotion(target.getBlockPos(), target.isUndead() ? Potions.STRONG_HEALING : Potions.STRONG_HARMING);
            }
            if (timer % 600 == 0) {
                summonMinions(this);
            }
        } else {
            if (getY() > -64) {
                heal(8);
            }
            timeSinceLastAttack = 0;
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 14 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.

the class LilithEntity method tryAttack.

@Override
public boolean tryAttack(Entity target) {
    boolean flag = super.tryAttack(target);
    if (flag && target instanceof LivingEntity) {
        ((LivingEntity) target).addStatusEffect(new StatusEffectInstance(BWStatusEffects.MORTAL_COIL, 1200));
        target.setOnFireFor(16);
        target.addVelocity(0, 0.2, 0);
        swingHand(Hand.MAIN_HAND);
    }
    return flag;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 15 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.

the class PricklyBeltCraftingRecipe method craft.

@Override
public ItemStack craft(CraftingInventory inv) {
    ItemStack pricklyBelt = null, potion = null;
    for (int i = 0; i < inv.size(); i++) {
        ItemStack stack = inv.getStack(i);
        if (stack.getItem() instanceof PricklyBeltItem) {
            pricklyBelt = stack.copy();
        } else if (stack.getItem() == Items.POTION) {
            potion = stack.copy();
        }
    }
    int uses = 1;
    List<StatusEffectInstance> effects = !PotionUtil.getCustomPotionEffects(potion).isEmpty() ? PotionUtil.getCustomPotionEffects(potion) : PotionUtil.getPotionEffects(potion);
    for (int i = 0; i < effects.size(); i++) {
        StatusEffectInstance effect = effects.get(i);
        int duration = effect.getDuration();
        int amplifier = effect.getAmplifier();
        while (duration > 600) {
            uses++;
            duration /= 2;
        }
        while (amplifier > 0) {
            uses += 2;
            amplifier--;
        }
        effects.set(i, new StatusEffectInstance(effect.getEffectType(), duration, amplifier, effect.isAmbient(), effect.shouldShowParticles(), effect.shouldShowIcon()));
    }
    if (potion.getOrCreateNbt().contains("PolymorphUUID")) {
        pricklyBelt.getOrCreateNbt().putUuid("PolymorphUUID", potion.getNbt().getUuid("PolymorphUUID"));
        pricklyBelt.getOrCreateNbt().putString("PolymorphName", potion.getNbt().getString("PolymorphName"));
    }
    PotionUtil.setCustomPotionEffects(pricklyBelt, effects);
    pricklyBelt.getOrCreateNbt().putInt("PotionUses", uses);
    return pricklyBelt;
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ItemStack(net.minecraft.item.ItemStack) PricklyBeltItem(moriyashiine.bewitchment.common.item.PricklyBeltItem)

Aggregations

StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)125 LivingEntity (net.minecraft.entity.LivingEntity)25 PlayerEntity (net.minecraft.entity.player.PlayerEntity)18 StatusEffect (net.minecraft.entity.effect.StatusEffect)15 ItemStack (net.minecraft.item.ItemStack)14 Inject (org.spongepowered.asm.mixin.injection.Inject)13 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)9 TypedActionResult (net.minecraft.util.TypedActionResult)7 Sprite (net.minecraft.client.texture.Sprite)4 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)4 Entity (net.minecraft.entity.Entity)4 MobEntity (net.minecraft.entity.mob.MobEntity)4 Box (net.minecraft.util.math.Box)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 List (java.util.List)3 Map (java.util.Map)3 StatusEffectSpriteManager (net.minecraft.client.texture.StatusEffectSpriteManager)3 ArrayList (java.util.ArrayList)2 HWGEntity (mod.azure.hwg.entity.HWGEntity)2 ThirstManager (net.dehydration.thirst.ThirstManager)2