Search in sources :

Example 51 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 52 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project HWG by cybercat-mods.

the class GrenadeEntity method remove.

@Override
public void remove(RemovalReason reason) {
    AreaEffectCloudEntity areaeffectcloudentity = new AreaEffectCloudEntity(this.world, this.getX(), this.getY(), this.getZ());
    if (this.getVariant() == 1)
        areaeffectcloudentity.setParticleType(this.getVariant() == 1 ? ParticleTypes.END_ROD : this.getVariant() == 2 ? ParticleTypes.EXPLOSION : this.getVariant() == 3 ? ParticleTypes.EXPLOSION : this.getVariant() == 4 ? ParticleTypes.LARGE_SMOKE : this.getVariant() == 5 ? ParticleTypes.FLASH : ParticleTypes.END_ROD);
    areaeffectcloudentity.setRadius(this.getVariant() == 4 ? 5.0F : 2.0F);
    areaeffectcloudentity.setDuration(this.getVariant() == 4 ? 120 : 2);
    if (this.getVariant() == 4) {
        areaeffectcloudentity.addEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 200, 1));
    }
    areaeffectcloudentity.updatePosition(this.getX(), this.getEyeY(), this.getZ());
    this.world.spawnEntity(areaeffectcloudentity);
    super.remove(reason);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity)

Example 53 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Client by MatHax.

the class WItemWithLabel method getStringToAppend.

private String getStringToAppend() {
    String str = "";
    if (itemStack.getItem() == Items.POTION) {
        List<StatusEffectInstance> effects = PotionUtil.getPotion(itemStack).getEffects();
        if (effects.size() > 0) {
            str += " ";
            StatusEffectInstance effect = effects.get(0);
            if (effect.getAmplifier() > 0)
                str += effect.getAmplifier() + 1 + " ";
            str += "(" + StatusEffectUtil.durationToString(effect, 1) + ")";
        }
    }
    return str;
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 54 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Client by MatHax.

the class PotionTimersHud method update.

@Override
public void update(HudRenderer renderer) {
    if (isInEditor()) {
        box.setSize(renderer.textWidth("Potion Timers 0:00"), renderer.textHeight());
        return;
    }
    double width = 0;
    double height = 0;
    int i = 0;
    for (StatusEffectInstance statusEffectInstance : mc.player.getStatusEffects()) {
        width = Math.max(width, renderer.textWidth(getString(statusEffectInstance)));
        height += renderer.textHeight();
        if (i > 0)
            height += 2;
        i++;
    }
    box.setSize(width, height);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 55 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Client by MatHax.

the class PotionTimersHud method render.

@Override
public void render(HudRenderer renderer) {
    double x = box.getX();
    double y = box.getY();
    if (isInEditor()) {
        renderer.text("Potion Timers 0:00", x, y, color);
        return;
    }
    int i = 0;
    for (StatusEffectInstance statusEffectInstance : mc.player.getStatusEffects()) {
        StatusEffect statusEffect = statusEffectInstance.getEffectType();
        int c = statusEffect.getColor();
        color.r = Color.toRGBAR(c);
        color.g = Color.toRGBAG(c);
        color.b = Color.toRGBAB(c);
        String text = getString(statusEffectInstance);
        renderer.text(text, x + box.alignX(renderer.textWidth(text)), y, color);
        color.r = color.g = color.b = 255;
        y += renderer.textHeight();
        if (i > 0)
            y += 2;
        i++;
    }
}
Also used : StatusEffect(net.minecraft.entity.effect.StatusEffect) 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