Search in sources :

Example 36 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project takumicraft by TNTModders.

the class EntityZombieCreeper method attackEntityFrom.

@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
    if (super.attackEntityFrom(source, amount)) {
        EntityLivingBase entitylivingbase = this.getAttackTarget();
        if (entitylivingbase == null && source.getTrueSource() instanceof EntityLivingBase) {
            entitylivingbase = (EntityLivingBase) source.getTrueSource();
        }
        int i = MathHelper.floor(this.posX);
        int j = MathHelper.floor(this.posY);
        int k = MathHelper.floor(this.posZ);
        if (entitylivingbase != null && this.world.getDifficulty() == EnumDifficulty.HARD && (double) this.rand.nextFloat() < this.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).getAttributeValue() && this.world.getGameRules().getBoolean("doMobSpawning")) {
            EntityZombieCreeper entityzombie = new EntityZombieCreeper(this.world);
            for (int l = 0; l < 50; ++l) {
                int i1 = i + MathHelper.getInt(this.rand, 7, 40) * MathHelper.getInt(this.rand, -1, 1);
                int j1 = j + MathHelper.getInt(this.rand, 7, 40) * MathHelper.getInt(this.rand, -1, 1);
                int k1 = k + MathHelper.getInt(this.rand, 7, 40) * MathHelper.getInt(this.rand, -1, 1);
                if (this.world.getBlockState(new BlockPos(i1, j1 - 1, k1)).isSideSolid(this.world, new BlockPos(i1, j1 - 1, k1), EnumFacing.UP) && this.world.getLightFromNeighbors(new BlockPos(i1, j1, k1)) < 10) {
                    entityzombie.setPosition(i1, j1, k1);
                    if (!this.world.isAnyPlayerWithinRangeAt((double) i1, (double) j1, (double) k1, 7.0D) && this.world.checkNoEntityCollision(entityzombie.getEntityBoundingBox(), entityzombie) && this.world.getCollisionBoxes(entityzombie, entityzombie.getEntityBoundingBox()).isEmpty() && !this.world.containsAnyLiquid(entityzombie.getEntityBoundingBox())) {
                        this.world.spawnEntity(entityzombie);
                        if (entitylivingbase != null) {
                            entityzombie.setAttackTarget(entitylivingbase);
                        }
                        entityzombie.onInitialSpawn(this.world.getDifficultyForLocation(new BlockPos(entityzombie)), null);
                        this.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement caller " + "charge", -0.05000000074505806D, 0));
                        entityzombie.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement " + "" + "" + "" + "" + "" + "callee charge", -0.05000000074505806D, 0));
                        break;
                    }
                }
            }
        }
        return true;
    } else {
        return false;
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 37 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project KalStuff by TEAMModding.

the class ItemDagger method getAttributeModifiers.

@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(slot, stack);
    if (slot == EntityEquipmentSlot.MAINHAND) {
        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double) this.attackDamage, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -1.2D, 0));
    }
    return multimap;
}
Also used : AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 38 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project BloodMagic by WayofTime.

the class ItemBoundAxe method getAttributeModifiers.

@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) {
    Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
    if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 11 : 2, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -3.0, 0));
    }
    return multimap;
}
Also used : AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 39 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project BloodMagic by WayofTime.

the class ItemSentientSword method getAttributeModifiers.

// TODO: Change attack speed.
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    Multimap<String, AttributeModifier> multimap = HashMultimap.create();
    if (slot == EntityEquipmentSlot.MAINHAND) {
        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0));
        multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0));
        multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), 2));
    }
    return multimap;
}
Also used : AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 40 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project BloodMagic by WayofTime.

the class ItemSentientPickaxe method getAttributeModifiers.

// TODO: Change attack speed.
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    Multimap<String, AttributeModifier> multimap = HashMultimap.create();
    if (slot == EntityEquipmentSlot.MAINHAND) {
        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0));
        multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0));
        multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), 2));
    }
    return multimap;
}
Also used : AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Aggregations

AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)116 Nonnull (javax.annotation.Nonnull)19 Multimap (com.google.common.collect.Multimap)14 IAttributeInstance (net.minecraft.entity.ai.attributes.IAttributeInstance)11 UUID (java.util.UUID)9 ItemStack (net.minecraft.item.ItemStack)9 IAttribute (net.minecraft.entity.ai.attributes.IAttribute)8 HashMultimap (com.google.common.collect.HashMultimap)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 Map (java.util.Map)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)4 Potion (net.minecraft.potion.Potion)4 PotionEffect (net.minecraft.potion.PotionEffect)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 Calendar (java.util.Calendar)3 EnergyUpgrade (crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2