Search in sources :

Example 16 with StatusEffectInstance

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

the class IllnessFortune method finish.

@Override
public boolean finish(ServerWorld world, PlayerEntity target) {
    target.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 600, 1));
    target.addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 600, 1));
    return super.finish(world, target);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 17 with StatusEffectInstance

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

the class PlayerEntityMixin method eat.

@Inject(method = "eatFood", at = @At("HEAD"))
private void eat(World world, ItemStack stack, CallbackInfoReturnable<ItemStack> callbackInfo) {
    if (!world.isClient) {
        FoodComponent foodComponent = stack.getItem().getFoodComponent();
        if (foodComponent != null) {
            boolean vampire = BewitchmentAPI.isVampire(this, true);
            if (vampire || (BewitchmentAPI.isWerewolf(this, true) && !foodComponent.isMeat())) {
                addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 100, 1));
                addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 100, 1));
                addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 100, 1));
                addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 1));
            }
            if (vampire && (stack.getItem() == BWObjects.GARLIC || stack.getItem() == BWObjects.GRILLED_GARLIC || stack.getItem() == BWObjects.GARLIC_BREAD)) {
                damage(BWDamageSources.MAGIC_COPY, Float.MAX_VALUE);
            }
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) FoodComponent(net.minecraft.item.FoodComponent) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 18 with StatusEffectInstance

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

the class ContractsComponent method serverTick.

@Override
public void serverTick() {
    int level = 0;
    for (int i = contracts.size() - 1; i >= 0; i--) {
        Contract.Instance instance = contracts.get(i);
        level += instance.cost;
        instance.contract.tick(obj);
        instance.duration--;
        if (instance.duration <= 0) {
            contracts.remove(i);
        }
    }
    if (level > 0) {
        obj.addStatusEffect(new StatusEffectInstance(BWStatusEffects.PACT, 10, level - 1, true, false));
        if (obj.getHealth() > obj.getMaxHealth()) {
            obj.setHealth(obj.getMaxHealth());
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) Contract(moriyashiine.bewitchment.api.registry.Contract)

Example 19 with StatusEffectInstance

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

the class TransformationComponent method serverTick.

@Override
public void serverTick() {
    boolean vampire = BewitchmentAPI.isVampire(obj, true);
    if (vampire) {
        boolean pledgedToLilith = BewitchmentAPI.isPledged(obj, BWPledges.LILITH);
        obj.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
        if (BWComponents.RESPAWN_TIMER_COMPONENT.get(obj).getRespawnTimer() <= 0 && obj.world.isDay() && !obj.world.isRaining() && obj.world.isSkyVisible(obj.getBlockPos()) && AllowVampireBurn.EVENT.invoker().allowBurn(obj)) {
            obj.setOnFireFor(8);
        }
        HungerManager hungerManager = obj.getHungerManager();
        if (BWComponents.BLOOD_COMPONENT.get(obj).getBlood() > 0) {
            if (AllowVampireHeal.EVENT.invoker().allowHeal(obj, pledgedToLilith)) {
                if (obj.age % (pledgedToLilith ? 30 : 40) == 0) {
                    if (obj.getHealth() < obj.getMaxHealth()) {
                        obj.heal(1);
                        hungerManager.addExhaustion(3);
                    }
                    if ((hungerManager.isNotFull() || hungerManager.getSaturationLevel() < 10) && BWComponents.BLOOD_COMPONENT.get(obj).drainBlood(1, false)) {
                        hungerManager.add(1, 20);
                    }
                }
            }
        } else {
            if (isAlternateForm()) {
                TransformationAbilityPacket.useAbility(obj, true);
            }
            hungerManager.addExhaustion(Float.MAX_VALUE);
        }
        if (isAlternateForm()) {
            hungerManager.addExhaustion(0.5f);
            if (!pledgedToLilith) {
                TransformationAbilityPacket.useAbility(obj, true);
            }
        }
    }
    if (BewitchmentAPI.isWerewolf(obj, true)) {
        AdditionalWerewolfDataComponent additionalWerewolfDataComponent = BWComponents.ADDITIONAL_WEREWOLF_DATA_COMPONENT.get(obj);
        boolean forced = additionalWerewolfDataComponent.isForcedTransformation();
        if (!obj.isCreative() && !obj.isSpectator() && !isAlternateForm() && obj.world.isNight() && BewitchmentAPI.getMoonPhase(obj.world) == 0 && obj.world.isSkyVisible(obj.getBlockPos())) {
            TransformationAbilityPacket.useAbility(obj, true);
            additionalWerewolfDataComponent.setForcedTransformation(true);
        } else if (isAlternateForm() && forced && (obj.world.isDay() || BewitchmentAPI.getMoonPhase(obj.world) != 0)) {
            TransformationAbilityPacket.useAbility(obj, true);
            additionalWerewolfDataComponent.setForcedTransformation(false);
        }
        if (isAlternateForm()) {
            obj.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
            Set<ItemStack> toDrop = new HashSet<>();
            obj.getArmorItems().forEach(stack -> {
                if (!stack.isEmpty()) {
                    toDrop.add(stack);
                }
            });
            if (BWUtil.isTool(obj.getMainHandStack())) {
                toDrop.add(obj.getMainHandStack());
            }
            if (BWUtil.isTool(obj.getOffHandStack())) {
                toDrop.add(obj.getOffHandStack());
            }
            toDrop.forEach(stack -> {
                int firstEmptyInventorySlot = getFirstEmptyInventorySlot();
                if (firstEmptyInventorySlot != -1) {
                    obj.getInventory().setStack(firstEmptyInventorySlot, stack.split(stack.getCount()));
                } else {
                    obj.dropStack(stack.split(stack.getCount()));
                }
            });
            if (!forced && !BewitchmentAPI.isPledged(obj, BWPledges.HERNE)) {
                TransformationAbilityPacket.useAbility(obj, true);
            }
        }
    }
}
Also used : AdditionalWerewolfDataComponent(moriyashiine.bewitchment.common.component.entity.AdditionalWerewolfDataComponent) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) HungerManager(net.minecraft.entity.player.HungerManager) ItemStack(net.minecraft.item.ItemStack) HashSet(java.util.HashSet)

Example 20 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project WK by witches-kitchen.

the class CuSithEntity method tryAttack.

@Override
public boolean tryAttack(Entity target) {
    boolean flag = super.tryAttack(target);
    Random rand = new Random();
    int i = rand.nextInt(100);
    if (i <= 33) {
        if (target instanceof LivingEntity) {
            ((LivingEntity) target).addStatusEffect(new StatusEffectInstance(WKStatusEffects.HORROR, 1000));
            this.playSound(WKSoundEvents.CUSITH_HOWL_EVENT, 0.8F, 0.7F);
        }
    }
    return flag;
}
Also used : Random(java.util.Random) SplittableRandom(java.util.SplittableRandom) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Aggregations

StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)128 LivingEntity (net.minecraft.entity.LivingEntity)25 PlayerEntity (net.minecraft.entity.player.PlayerEntity)20 StatusEffect (net.minecraft.entity.effect.StatusEffect)16 ItemStack (net.minecraft.item.ItemStack)15 Inject (org.spongepowered.asm.mixin.injection.Inject)13 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)10 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 StatusEffectSpriteManager (net.minecraft.client.texture.StatusEffectSpriteManager)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 HWGEntity (mod.azure.hwg.entity.HWGEntity)2 ThirstManager (net.dehydration.thirst.ThirstManager)2