Search in sources :

Example 1 with StatusEffectAccess

use of party.lemons.biomemakeover.util.access.StatusEffectAccess in project Biome-Makeover by Lemonszz.

the class WitchEntityMixin method tickMovement.

@Inject(at = @At("TAIL"), method = "tickMovement")
public void tickMovement(CallbackInfo cbi) {
    if (!isDrinking()) {
        if (random.nextFloat() < 0.10) {
            boolean found = false;
            for (StatusEffectInstance effect : getStatusEffects()) if (((StatusEffectAccess) effect.getEffectType()).bm_getType() == StatusEffectType.HARMFUL) {
                found = true;
                break;
            }
            if (found) {
                this.equipStack(EquipmentSlot.MAINHAND, PotionUtil.setPotion(new ItemStack(Items.POTION), BMPotions.ANTIDOTE_POT));
                this.drinkTimeLeft = this.getMainHandStack().getMaxUseTime();
                this.setDrinking(true);
                if (!this.isSilent()) {
                    this.world.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F, 0.8F + this.random.nextFloat() * 0.4F);
                }
                EntityAttributeInstance entityAttributeInstance = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
                entityAttributeInstance.removeModifier(DRINKING_SPEED_PENALTY_MODIFIER);
                entityAttributeInstance.addTemporaryModifier(DRINKING_SPEED_PENALTY_MODIFIER);
            }
        }
    }
}
Also used : StatusEffectAccess(party.lemons.biomemakeover.util.access.StatusEffectAccess) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ItemStack(net.minecraft.item.ItemStack) EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

EntityAttributeInstance (net.minecraft.entity.attribute.EntityAttributeInstance)1 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)1 ItemStack (net.minecraft.item.ItemStack)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 StatusEffectAccess (party.lemons.biomemakeover.util.access.StatusEffectAccess)1