Search in sources :

Example 11 with EntityAttributeInstance

use of net.minecraft.entity.attribute.EntityAttributeInstance in project Biome-Makeover by Lemonszz.

the class ToadEntity method mobTick.

public void mobTick() {
    eatCooldown--;
    if (eatCooldown <= 0 && !hasTongueEntity()) {
        List<ToadTargetEntity> targets = world.getEntitiesByClass(ToadTargetEntity.class, getBoundingBox().expand(3, 3, 3), (e) -> canSee(e) && !e.isBeingEaten());
        ToadTargetEntity closest = world.getClosestEntity(targets, predicate, this, getX(), getY(), getZ());
        if (!canUseTongue() || closest == null || closest.hasVehicle() || targets.isEmpty())
            clearTongueEntity();
        else {
            eatCooldown = 350;
            setTongueEntity(closest);
        }
    } else {
        Entity e = world.getEntityById(getTongueEntityID());
        if (!canUseTongue() || e == null || !e.isAlive())
            clearTongueEntity();
    }
    if (this.ticksUntilJump > 0) {
        --this.ticksUntilJump;
    }
    if (ticksUntilJump <= 0 && moveControl.isMoving()) {
        ticksUntilJump = RandomUtil.randomRange(20, 100);
        jump();
        EntityAttributeInstance entityAttributeInstance = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
        entityAttributeInstance.removeModifier(JUMP_SPEED_BOOST);
        entityAttributeInstance.addTemporaryModifier(JUMP_SPEED_BOOST_MOD);
        this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F);
    }
    if (onGround && !onGroundPrev) {
        this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).removeModifier(JUMP_SPEED_BOOST_MOD);
    }
    onGroundPrev = onGround;
}
Also used : MobEntity(net.minecraft.entity.mob.MobEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) ExperienceOrbEntity(net.minecraft.entity.ExperienceOrbEntity) Entity(net.minecraft.entity.Entity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance)

Example 12 with EntityAttributeInstance

use of net.minecraft.entity.attribute.EntityAttributeInstance in project Biome-Makeover by Lemonszz.

the class BMEnchantment method removeAttributes.

public void removeAttributes(LivingEntity entity, EquipmentSlot slot) {
    for (Map.Entry<EntityAttribute, EntityAttributeModifier> attributeEntry : this.attributeModifiers.entrySet()) {
        UUID slotID = MathUtils.uuidFromString(slot.toString());
        EntityAttributeInstance entityAttributeInstance = entity.getAttributes().getCustomInstance(attributeEntry.getKey());
        if (entityAttributeInstance != null) {
            EntityAttributeModifier mod = entityAttributeInstance.getModifier(slotID);
            if (mod != null)
                entityAttributeInstance.removeModifier(mod);
            else
                System.out.println("ERROR REMOVING MODIFIER: DOESNT EXIST??? : " + entityAttributeInstance.getAttribute().getTranslationKey());
        }
    }
}
Also used : EntityAttribute(net.minecraft.entity.attribute.EntityAttribute) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) UUID(java.util.UUID) Map(java.util.Map) EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance)

Aggregations

EntityAttributeInstance (net.minecraft.entity.attribute.EntityAttributeInstance)12 EntityAttributeModifier (net.minecraft.entity.attribute.EntityAttributeModifier)5 Map (java.util.Map)2 UUID (java.util.UUID)2 EntityAttribute (net.minecraft.entity.attribute.EntityAttribute)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 Entity (net.minecraft.entity.Entity)1 ExperienceOrbEntity (net.minecraft.entity.ExperienceOrbEntity)1 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)1 MobEntity (net.minecraft.entity.mob.MobEntity)1 AnimalEntity (net.minecraft.entity.passive.AnimalEntity)1 PassiveEntity (net.minecraft.entity.passive.PassiveEntity)1 ItemStack (net.minecraft.item.ItemStack)1 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1 StatusEffectAccess (party.lemons.biomemakeover.util.access.StatusEffectAccess)1