Search in sources :

Example 6 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project Minechem by iopleke.

the class AugmentSharp method getAttributeModifiers.

@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack, int level) {
    Multimap multimap = super.getAttributeModifiers(stack, level);
    multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(AugmentedItem.itemUUID, "Weapon modifier", (double) level, 0));
    return multimap;
}
Also used : Multimap(com.google.common.collect.Multimap) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 7 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project MorePlanets by SteveKunG.

the class EntityInfectedZombie method onInitialSpawn.

@Override
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData data) {
    this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1));
    float f = difficulty.getClampedAdditionalDifficulty();
    this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * f);
    if (data == null) {
        data = new GroupData(this.world.rand.nextFloat() < net.minecraftforge.common.ForgeModContainer.zombieBabyChance);
    }
    if (data instanceof GroupData) {
        GroupData entityzombie$groupdata = (GroupData) data;
        if (entityzombie$groupdata.isChild) {
            this.setChild(true);
            if (this.world.rand.nextFloat() < 0.05D) {
                List<EntityInfectedChicken> list = this.world.getEntitiesWithinAABB(EntityInfectedChicken.class, this.getEntityBoundingBox().grow(5.0D, 3.0D, 5.0D), EntitySelectors.IS_STANDALONE);
                if (!list.isEmpty()) {
                    EntityInfectedChicken entitychicken = list.get(0);
                    entitychicken.setChickenJockey(true);
                    this.startRiding(entitychicken);
                }
            } else if (this.world.rand.nextFloat() < 0.05D) {
                EntityInfectedChicken entitychicken1 = new EntityInfectedChicken(this.world);
                entitychicken1.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
                entitychicken1.onInitialSpawn(difficulty, (IEntityLivingData) null);
                entitychicken1.setChickenJockey(true);
                this.world.spawnEntity(entitychicken1);
                this.startRiding(entitychicken1);
            }
        }
    }
    this.setBreakDoorsAItask(this.rand.nextFloat() < f * 0.1F);
    this.setEquipmentBasedOnDifficulty(difficulty);
    this.setEnchantmentBasedOnDifficulty(difficulty);
    if (this.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == null) {
        Calendar calendar = this.world.getCurrentDate();
        if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F) {
            this.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.LIT_PUMPKIN : Blocks.PUMPKIN));
            this.inventoryArmorDropChances[EntityEquipmentSlot.HEAD.getIndex()] = 0.0F;
        }
    }
    this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextDouble() * 0.05000000074505806D, 0));
    double d0 = this.rand.nextDouble() * 1.5D * f;
    if (d0 > 1.0D) {
        this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, 2));
    }
    if (this.rand.nextFloat() < f * 0.05F) {
        this.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 0.25D + 0.5D, 0));
        this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 3.0D + 1.0D, 2));
        this.setBreakDoorsAItask(true);
    }
    return data;
}
Also used : Calendar(java.util.Calendar) IEntityLivingData(net.minecraft.entity.IEntityLivingData) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier) ItemStack(net.minecraft.item.ItemStack)

Example 8 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project Overloaded by CJ-MC-Mods.

the class ItemMultiChestplate method getItemAttributeModifiers.

@Override
@Nonnull
public Multimap<String, AttributeModifier> getItemAttributeModifiers(@Nullable EntityEquipmentSlot equipmentSlot) {
    Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
    if (equipmentSlot == this.armorType) {
        multimap.put(SharedMonsterAttributes.ARMOR.getName(), new AttributeModifier(ARMOR_MODIFIERS[equipmentSlot.getIndex()], "Armor modifier", 100, 0));
        multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(ARMOR_MODIFIERS[equipmentSlot.getIndex()], "Max Health", 100, 0));
        multimap.put(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName(), new AttributeModifier(ARMOR_MODIFIERS[equipmentSlot.getIndex()], "Armor toughness", 100, 0));
    }
    return multimap;
}
Also used : AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier) Nonnull(javax.annotation.Nonnull)

Example 9 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project ArsMagica2 by Mithion.

the class Freedom method applyEffect.

@Override
public boolean applyEffect(EntityPlayer player, World world, ItemStack stack, ImbuementApplicationTypes matchedType, Object... params) {
    ModifiableAttributeInstance instance = (ModifiableAttributeInstance) player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.movementSpeed);
    ArrayList<AttributeModifier> toRemove = new ArrayList<AttributeModifier>();
    Collection c = instance.func_111122_c();
    ArrayList arraylist = new ArrayList(c);
    Iterator iterator = arraylist.iterator();
    while (iterator.hasNext()) {
        AttributeModifier attributemodifier = (AttributeModifier) iterator.next();
        if (attributemodifier.getOperation() == 2 && attributemodifier.getAmount() < 0.0f) {
            toRemove.add(attributemodifier);
        }
    }
    for (AttributeModifier modifier : toRemove) {
        instance.removeModifier(modifier);
    }
    return toRemove.size() > 0;
}
Also used : ModifiableAttributeInstance(net.minecraft.entity.ai.attributes.ModifiableAttributeInstance) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Collection(java.util.Collection) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 10 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project ArsMagica2 by Mithion.

the class BuffStatModifiers method applyAllModifiers.

private void applyAllModifiers(EntityLivingBase entity, KeyValuePair<IAttribute, AttributeModifier>... modifiers) {
    for (KeyValuePair<IAttribute, AttributeModifier> entry : modifiers) {
        IAttributeInstance inst = entity.getEntityAttribute(entry.getKey());
        if (inst == null)
            continue;
        AttributeModifier currentModifier = inst.getModifier(entry.getValue().getID());
        if (currentModifier != entry.getValue()) {
            if (currentModifier != null) {
                inst.removeModifier(currentModifier);
            }
            inst.applyModifier(entry.getValue());
        }
    }
}
Also used : IAttribute(net.minecraft.entity.ai.attributes.IAttribute) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Aggregations

AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)16 Multimap (com.google.common.collect.Multimap)4 IAttribute (net.minecraft.entity.ai.attributes.IAttribute)3 IAttributeInstance (net.minecraft.entity.ai.attributes.IAttributeInstance)3 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 Nonnull (javax.annotation.Nonnull)1 IEntityLivingData (net.minecraft.entity.IEntityLivingData)1 ModifiableAttributeInstance (net.minecraft.entity.ai.attributes.ModifiableAttributeInstance)1 ItemStack (net.minecraft.item.ItemStack)1 Potion (net.minecraft.potion.Potion)1 PotionEffect (net.minecraft.potion.PotionEffect)1 Tuple (net.minecraft.util.Tuple)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1