Search in sources :

Example 1 with StatusEffectInstanceAccessor

use of mathax.client.mixin.StatusEffectInstanceAccessor in project Client by MatHax.

the class PotionSpoof method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    for (StatusEffect statusEffect : potions.get().keySet()) {
        int level = potions.get().getInt(statusEffect);
        if (level <= 0)
            continue;
        if (mc.player.hasStatusEffect(statusEffect)) {
            StatusEffectInstance instance = mc.player.getStatusEffect(statusEffect);
            ((StatusEffectInstanceAccessor) instance).setAmplifier(level - 1);
            if (instance.getDuration() < 20)
                ((StatusEffectInstanceAccessor) instance).setDuration(20);
        } else
            mc.player.addStatusEffect(new StatusEffectInstance(statusEffect, 20, level - 1));
    }
}
Also used : StatusEffect(net.minecraft.entity.effect.StatusEffect) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) StatusEffectInstanceAccessor(mathax.client.mixin.StatusEffectInstanceAccessor) EventHandler(mathax.client.eventbus.EventHandler)

Example 2 with StatusEffectInstanceAccessor

use of mathax.client.mixin.StatusEffectInstanceAccessor in project Client by MatHax.

the class SpeedMine method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (mode.get() == Mode.Normal)
        return;
    int amplifier = mode.get() == Mode.Haste2 ? 1 : 0;
    if (!mc.player.hasStatusEffect(HASTE))
        mc.player.addStatusEffect(new StatusEffectInstance(HASTE, 255, amplifier, false, false, false));
    StatusEffectInstance effect = mc.player.getStatusEffect(HASTE);
    ((StatusEffectInstanceAccessor) effect).setAmplifier(amplifier);
    if (effect.getDuration() < 20)
        ((StatusEffectInstanceAccessor) effect).setDuration(20);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) StatusEffectInstanceAccessor(mathax.client.mixin.StatusEffectInstanceAccessor) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

EventHandler (mathax.client.eventbus.EventHandler)2 StatusEffectInstanceAccessor (mathax.client.mixin.StatusEffectInstanceAccessor)2 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)2 StatusEffect (net.minecraft.entity.effect.StatusEffect)1