Search in sources :

Example 61 with StatusEffectInstance

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

the class AbilityHelper method stealSpeedFromTarget.

public static void stealSpeedFromTarget(LivingEntity user, LivingEntity target, int amplifier) {
    StatusEffectInstance speed = new StatusEffectInstance(StatusEffects.SPEED, 80, amplifier);
    StatusEffectInstance slowness = new StatusEffectInstance(StatusEffects.SLOWNESS, 80, amplifier);
    user.addStatusEffect(speed);
    target.addStatusEffect(slowness);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 62 with StatusEffectInstance

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

the class AbilityHelper method causeFreezing.

public static void causeFreezing(LivingEntity target, int amplifier) {
    StatusEffectInstance freezing = new StatusEffectInstance(StatusEffects.SLOWNESS, 60, amplifier);
    StatusEffectInstance miningFatigue = new StatusEffectInstance(StatusEffects.MINING_FATIGUE, 60, amplifier);
    target.addStatusEffect(freezing);
    target.addStatusEffect(miningFatigue);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 63 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project BedrockIfy by juancarloscp52.

the class InGameHudMixin method renderStatusEffectOverlay.

/**
 * Render the status effect overlay with the screen border distance applied.
 */
@Inject(method = "renderStatusEffectOverlay", at = @At("HEAD"), cancellable = true)
public void renderStatusEffectOverlay(MatrixStack matrixStack, CallbackInfo info) {
    Collection<StatusEffectInstance> collection = Objects.requireNonNull(this.client.player).getStatusEffects();
    if (!collection.isEmpty()) {
        RenderSystem.enableBlend();
        int beneficialEffects = 0;
        int harmfulEffects = 0;
        StatusEffectSpriteManager statusEffectSpriteManager = this.client.getStatusEffectSpriteManager();
        List<Runnable> list = Lists.newArrayListWithExpectedSize(collection.size());
        this.client.getTextureManager().bindTexture(HandledScreen.BACKGROUND_TEXTURE);
        for (StatusEffectInstance statusEffectInstance : Ordering.natural().reverse().sortedCopy(collection)) {
            StatusEffect statusEffect = statusEffectInstance.getEffectType();
            if (statusEffectInstance.shouldShowIcon()) {
                int x = this.scaledWidth - screenBorder;
                int y = 1 + screenBorder;
                if (this.client.isDemo()) {
                    y += 15;
                }
                if (statusEffect.isBeneficial()) {
                    ++beneficialEffects;
                    x -= 25 * beneficialEffects;
                } else {
                    ++harmfulEffects;
                    x -= 25 * harmfulEffects;
                    y += 26;
                }
                RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
                float spriteAlpha = 1.0F;
                if (statusEffectInstance.isAmbient()) {
                    this.drawTexture(matrixStack, x, y, 165, 166, 24, 24);
                } else {
                    this.drawTexture(matrixStack, x, y, 141, 166, 24, 24);
                    if (statusEffectInstance.getDuration() <= 200) {
                        int m = 10 - statusEffectInstance.getDuration() / 20;
                        spriteAlpha = MathHelper.clamp((float) statusEffectInstance.getDuration() / 10.0F / 5.0F * 0.5F, 0.0F, 0.5F) + MathHelper.cos((float) statusEffectInstance.getDuration() * 3.1415927F / 5.0F) * MathHelper.clamp((float) m / 10.0F * 0.25F, 0.0F, 0.25F);
                    }
                }
                Sprite sprite = statusEffectSpriteManager.getSprite(statusEffect);
                int finalX = x + 3;
                int finalY = y + 3;
                float finalAlpha = spriteAlpha;
                list.add(() -> {
                    this.client.getTextureManager().bindTexture(sprite.getAtlas().getId());
                    RenderSystem.color4f(1.0F, 1.0F, 1.0F, finalAlpha);
                    drawSprite(matrixStack, finalX, finalY, this.getZOffset(), 18, 18, sprite);
                });
            }
        }
        list.forEach(Runnable::run);
    }
    info.cancel();
}
Also used : StatusEffect(net.minecraft.entity.effect.StatusEffect) Sprite(net.minecraft.client.texture.Sprite) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) StatusEffectSpriteManager(net.minecraft.client.texture.StatusEffectSpriteManager) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 64 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project ImmersivePortalsMod by qouteall.

the class EndPortalEntity method onEntityTeleportedOnServer.

@Override
public void onEntityTeleportedOnServer(Entity entity) {
    if (shouldAddSlowFalling(entity)) {
        LivingEntity livingEntity = (LivingEntity) entity;
        livingEntity.addPotionEffect(new StatusEffectInstance(StatusEffects.SLOW_FALLING, // duration
        120, // amplifier
        1));
    }
    if (entity instanceof ServerPlayerEntity) {
        generateObsidianPlatform();
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 65 with StatusEffectInstance

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

the class EnchantmentEffects method applyChilling.

public static void applyChilling(LivingEntity wearer, LivingEntity livingEntity) {
    int chillingLevel = EnchantmentHelper.getEquipmentLevel(EnchantsRegistry.enchants.get(CHILLING), wearer);
    if (chillingLevel > 0) {
        livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 20 * chillingLevel, chillingLevel * 2 - 1));
        livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.MINING_FATIGUE, 20 * chillingLevel, chillingLevel * 2 - 1));
    }
}
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