Search in sources :

Example 56 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project LevelZ by Globox1997.

the class LivingEntityMixin method tryUseTotemMixin.

@Inject(method = "tryUseTotem", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/Hand;values()[Lnet/minecraft/util/Hand;"), cancellable = true)
private void tryUseTotemMixin(DamageSource source, CallbackInfoReturnable<Boolean> info) {
    if ((Object) this instanceof PlayerEntity) {
        PlayerEntity player = (PlayerEntity) (Object) this;
        if (((PlayerStatsManagerAccess) player).getPlayerStatsManager(player).getLevel("luck") >= ConfigInit.CONFIG.maxLevel && player.world.random.nextFloat() < ConfigInit.CONFIG.luckSurviveChance) {
            player.setHealth(1.0F);
            player.clearStatusEffects();
            player.addStatusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 100, 1));
            player.addStatusEffect(new StatusEffectInstance(StatusEffects.FIRE_RESISTANCE, 600, 0));
            info.setReturnValue(true);
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 57 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Carrier by GabrielOlvH.

the class ServerWorldTickCallback method onEndTick.

@Override
public void onEndTick(ServerWorld serverWorld) {
    for (ServerPlayerEntity player : serverWorld.getPlayers()) {
        CarrierComponent carrier = Carrier.HOLDER.get(player);
        CarryingData carrying = carrier.getCarryingData();
        if (carrying != null) {
            Config config = Carrier.CONFIG;
            if (config.getSlownessLevel() > 0)
                player.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 20, config.getSlownessLevel() - 1));
            if (config.getHungerExhaustion() > 0)
                player.getHungerManager().addExhaustion(config.getHungerExhaustion());
        }
    }
}
Also used : CarryingData(me.steven.carrier.api.CarryingData) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) CarrierComponent(me.steven.carrier.api.CarrierComponent)

Example 58 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDungeonsWeapons by chronosacaria.

the class RampagingEnchantmentMixin method onRampagingEnchantmentKill.

@Inject(at = @At("HEAD"), method = "onDeath", cancellable = true)
private void onRampagingEnchantmentKill(DamageSource source, CallbackInfo ci) {
    if (!(source.getAttacker() instanceof PlayerEntity))
        return;
    LivingEntity user = (LivingEntity) source.getAttacker();
    ItemStack mainHandStack = null;
    if (user != null) {
        mainHandStack = user.getMainHandStack();
    }
    boolean uniqueWeaponFlag = false;
    if (McdwEnchantsConfig.getValue("rampaging")) {
        if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.RAMPAGING, mainHandStack) >= 1)) {
            int level = EnchantmentHelper.getLevel(EnchantsRegistry.RAMPAGING, mainHandStack);
            float rampagingRand = user.getRandom().nextFloat();
            if (rampagingRand <= 0.1F) {
                StatusEffectInstance rampage = new StatusEffectInstance(StatusEffects.HASTE, level * 100, 2, false, false);
                user.addStatusEffect(rampage);
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ItemStack(net.minecraft.item.ItemStack) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 59 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDungeonsWeapons by chronosacaria.

the class AOECloudHelper method spawnRegenCloud.

// Regen Cloud
public static void spawnRegenCloud(LivingEntity user, int amplifier) {
    AreaEffectCloudEntity areaEffectCloudEntity = new AreaEffectCloudEntity(user.world, user.getX(), user.getY(), user.getZ());
    areaEffectCloudEntity.setOwner(user);
    areaEffectCloudEntity.setRadius(5.0F);
    areaEffectCloudEntity.setRadiusOnUse(-0.5F);
    areaEffectCloudEntity.setWaitTime(10);
    areaEffectCloudEntity.setDuration(100);
    StatusEffectInstance regeneration = new StatusEffectInstance(StatusEffects.REGENERATION, 100, amplifier);
    areaEffectCloudEntity.addEffect(regeneration);
    user.world.spawnEntity(areaEffectCloudEntity);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 60 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDungeonsWeapons by chronosacaria.

the class AOECloudHelper method spawnPoisonCloud.

// Poison Cloud
public static void spawnPoisonCloud(LivingEntity user, LivingEntity target, int amplifier) {
    AreaEffectCloudEntity areaEffectCloudEntity = new AreaEffectCloudEntity(target.world, target.getX(), target.getY(), target.getZ());
    areaEffectCloudEntity.setOwner(user);
    areaEffectCloudEntity.setRadius(5.0F);
    areaEffectCloudEntity.setRadiusOnUse(-0.5F);
    areaEffectCloudEntity.setWaitTime(10);
    areaEffectCloudEntity.setDuration(60);
    StatusEffectInstance poison = new StatusEffectInstance(StatusEffects.POISON, 60, amplifier);
    areaEffectCloudEntity.addEffect(poison);
    target.world.spawnEntity(areaEffectCloudEntity);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Aggregations

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