Java 类net.minecraft.entity.ai.attributes.AttributeModifier 实例源码

项目:CustomWorldGen    文件:EntityLiving.java   
/**
 * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
 * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
 */
@Nullable
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
{
    this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1));

    if (this.rand.nextFloat() < 0.05F)
    {
        this.setLeftHanded(true);
    }
    else
    {
        this.setLeftHanded(false);
    }

    return livingdata;
}
项目:Backmemed    文件:SharedMonsterAttributes.java   
@Nullable

    /**
     * Creates an AttributeModifier from an NBTTagCompound
     */
    public static AttributeModifier readAttributeModifierFromNBT(NBTTagCompound compound)
    {
        UUID uuid = compound.getUniqueId("UUID");

        try
        {
            return new AttributeModifier(uuid, compound.getString("Name"), compound.getDouble("Amount"), compound.getInteger("Operation"));
        }
        catch (Exception exception)
        {
            LOGGER.warn("Unable to create attribute: {}", new Object[] {exception.getMessage()});
            return null;
        }
    }
项目:CustomWorldGen    文件:SetAttributes.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    for (SetAttributes.Modifier setattributes$modifier : this.modifiers)
    {
        UUID uuid = setattributes$modifier.uuid;

        if (uuid == null)
        {
            uuid = UUID.randomUUID();
        }

        EntityEquipmentSlot entityequipmentslot = setattributes$modifier.slots[rand.nextInt(setattributes$modifier.slots.length)];
        stack.addAttributeModifier(setattributes$modifier.attributeName, new AttributeModifier(uuid, setattributes$modifier.modifierName, (double)setattributes$modifier.amount.generateFloat(rand), setattributes$modifier.operation), entityequipmentslot);
    }

    return stack;
}
项目:Infernum    文件:EntityPigZombieMage.java   
@Nullable
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) {
    livingdata = super.onInitialSpawn(difficulty, livingdata);
    float f = difficulty.getClampedAdditionalDifficulty();
    this.setCanPickUpLoot(false);
    this.setEquipmentBasedOnDifficulty(difficulty);
    this.setEnchantmentBasedOnDifficulty(difficulty);
    this.setCombatTask();

    this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).applyModifier(
            new AttributeModifier("Random spawn bonus", this.rand.nextDouble() * 0.05000000074505806D, 0));
    double d0 = this.rand.nextDouble() * 1.5D * (double) f;

    if (d0 > 1.0D) {
        this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE)
                .applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, 2));
    }

    return livingdata;
}
项目:DecompiledMinecraft    文件:SharedMonsterAttributes.java   
/**
 * Creates an NBTTagCompound from an AttributeInstance, including its AttributeModifiers
 */
private static NBTTagCompound writeAttributeInstanceToNBT(IAttributeInstance p_111261_0_)
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    IAttribute iattribute = p_111261_0_.getAttribute();
    nbttagcompound.setString("Name", iattribute.getAttributeUnlocalizedName());
    nbttagcompound.setDouble("Base", p_111261_0_.getBaseValue());
    Collection<AttributeModifier> collection = p_111261_0_.func_111122_c();

    if (collection != null && !collection.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (AttributeModifier attributemodifier : collection)
        {
            if (attributemodifier.isSaved())
            {
                nbttaglist.appendTag(writeAttributeModifierToNBT(attributemodifier));
            }
        }

        nbttagcompound.setTag("Modifiers", nbttaglist);
    }

    return nbttagcompound;
}
项目:Backmemed    文件:SetAttributes.java   
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    for (SetAttributes.Modifier setattributes$modifier : this.modifiers)
    {
        UUID uuid = setattributes$modifier.uuid;

        if (uuid == null)
        {
            uuid = UUID.randomUUID();
        }

        EntityEquipmentSlot entityequipmentslot = setattributes$modifier.slots[rand.nextInt(setattributes$modifier.slots.length)];
        stack.addAttributeModifier(setattributes$modifier.attributeName, new AttributeModifier(uuid, setattributes$modifier.modifierName, (double)setattributes$modifier.amount.generateFloat(rand), setattributes$modifier.operation), entityequipmentslot);
    }

    return stack;
}
项目:DecompiledMinecraft    文件:S20PacketEntityProperties.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeVarIntToBuffer(this.entityId);
    buf.writeInt(this.field_149444_b.size());

    for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : this.field_149444_b)
    {
        buf.writeString(s20packetentityproperties$snapshot.func_151409_a());
        buf.writeDouble(s20packetentityproperties$snapshot.func_151410_b());
        buf.writeVarIntToBuffer(s20packetentityproperties$snapshot.func_151408_c().size());

        for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c())
        {
            buf.writeUuid(attributemodifier.getID());
            buf.writeDouble(attributemodifier.getAmount());
            buf.writeByte(attributemodifier.getOperation());
        }
    }
}
项目:CustomWorldGen    文件:SharedMonsterAttributes.java   
/**
 * Creates an NBTTagCompound from an AttributeInstance, including its AttributeModifiers
 */
private static NBTTagCompound writeAttributeInstanceToNBT(IAttributeInstance instance)
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    IAttribute iattribute = instance.getAttribute();
    nbttagcompound.setString("Name", iattribute.getAttributeUnlocalizedName());
    nbttagcompound.setDouble("Base", instance.getBaseValue());
    Collection<AttributeModifier> collection = instance.getModifiers();

    if (collection != null && !collection.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (AttributeModifier attributemodifier : collection)
        {
            if (attributemodifier.isSaved())
            {
                nbttaglist.appendTag(writeAttributeModifierToNBT(attributemodifier));
            }
        }

        nbttagcompound.setTag("Modifiers", nbttaglist);
    }

    return nbttagcompound;
}
项目:CustomWorldGen    文件:SharedMonsterAttributes.java   
/**
 * Creates an AttributeModifier from an NBTTagCompound
 */
@Nullable
public static AttributeModifier readAttributeModifierFromNBT(NBTTagCompound compound)
{
    UUID uuid = compound.getUniqueId("UUID");

    try
    {
        return new AttributeModifier(uuid, compound.getString("Name"), compound.getDouble("Amount"), compound.getInteger("Operation"));
    }
    catch (Exception exception)
    {
        LOGGER.warn("Unable to create attribute: {}", new Object[] {exception.getMessage()});
        return null;
    }
}
项目:Mods    文件:ItemWeapon.java   
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(slot, stack);

    if (slot == EntityEquipmentSlot.MAINHAND && getData(stack) != ItemFromData.BLANK_DATA && stack.hasTagCompound()) {
        int heads=Math.min((int)TF2Attribute.getModifier("Kill Count", stack, 0, null), stack.getTagCompound().getInteger("Heads"));
        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(),
                new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier",
                        this.getWeaponDamage(stack, null, null) * this.getWeaponPelletCount(stack, null) - 1, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(
                ATTACK_SPEED_MODIFIER, "Weapon modifier", -4 + (1000D / this.getFiringSpeed(stack, null)), 0));
        float addHealth = TF2Attribute.getModifier("Health", stack, 0, null)+heads * TF2Attribute.getModifier("Max Health Kill", stack, 0, null);
        if (addHealth != 0)
            multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(),
                    new AttributeModifier(HEALTH_MODIFIER, "Weapon modifier", addHealth, 0));
        float addSpeed = TF2Attribute.getModifier("Speed", stack, 1 + heads * TF2Attribute.getModifier("Speed Kill", stack, 0, null), null);
        if (addSpeed != 1)
            multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(),
                    new AttributeModifier(SPEED_MODIFIER, "Weapon modifier", addSpeed - 1, 2));
    }
    return multimap;
}
项目:Backmemed    文件:SPacketEntityProperties.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.entityId = buf.readVarIntFromBuffer();
    int i = buf.readInt();

    for (int j = 0; j < i; ++j)
    {
        String s = buf.readStringFromBuffer(64);
        double d0 = buf.readDouble();
        List<AttributeModifier> list = Lists.<AttributeModifier>newArrayList();
        int k = buf.readVarIntFromBuffer();

        for (int l = 0; l < k; ++l)
        {
            UUID uuid = buf.readUuid();
            list.add(new AttributeModifier(uuid, "Unknown synced attribute modifier", buf.readDouble(), buf.readByte()));
        }

        this.snapshots.add(new SPacketEntityProperties.Snapshot(s, d0, list));
    }
}
项目:Backmemed    文件:SharedMonsterAttributes.java   
/**
 * Creates an NBTTagCompound from an AttributeInstance, including its AttributeModifiers
 */
private static NBTTagCompound writeAttributeInstanceToNBT(IAttributeInstance instance)
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    IAttribute iattribute = instance.getAttribute();
    nbttagcompound.setString("Name", iattribute.getAttributeUnlocalizedName());
    nbttagcompound.setDouble("Base", instance.getBaseValue());
    Collection<AttributeModifier> collection = instance.getModifiers();

    if (collection != null && !collection.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (AttributeModifier attributemodifier : collection)
        {
            if (attributemodifier.isSaved())
            {
                nbttaglist.appendTag(writeAttributeModifierToNBT(attributemodifier));
            }
        }

        nbttagcompound.setTag("Modifiers", nbttaglist);
    }

    return nbttagcompound;
}
项目:BaseClient    文件:SharedMonsterAttributes.java   
private static void applyModifiersToAttributeInstance(IAttributeInstance p_111258_0_, NBTTagCompound p_111258_1_)
{
    p_111258_0_.setBaseValue(p_111258_1_.getDouble("Base"));

    if (p_111258_1_.hasKey("Modifiers", 9))
    {
        NBTTagList nbttaglist = p_111258_1_.getTagList("Modifiers", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.getCompoundTagAt(i));

            if (attributemodifier != null)
            {
                AttributeModifier attributemodifier1 = p_111258_0_.getModifier(attributemodifier.getID());

                if (attributemodifier1 != null)
                {
                    p_111258_0_.removeModifier(attributemodifier1);
                }

                p_111258_0_.applyModifier(attributemodifier);
            }
        }
    }
}
项目:BaseClient    文件:S20PacketEntityProperties.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.entityId = buf.readVarIntFromBuffer();
    int i = buf.readInt();

    for (int j = 0; j < i; ++j)
    {
        String s = buf.readStringFromBuffer(64);
        double d0 = buf.readDouble();
        List<AttributeModifier> list = Lists.<AttributeModifier>newArrayList();
        int k = buf.readVarIntFromBuffer();

        for (int l = 0; l < k; ++l)
        {
            UUID uuid = buf.readUuid();
            list.add(new AttributeModifier(uuid, "Unknown synced attribute modifier", buf.readDouble(), buf.readByte()));
        }

        this.field_149444_b.add(new S20PacketEntityProperties.Snapshot(s, d0, list));
    }
}
项目:BaseClient    文件:S20PacketEntityProperties.java   
/**
 * Writes the raw packet data to the data stream.
 */
public void writePacketData(PacketBuffer buf) throws IOException
{
    buf.writeVarIntToBuffer(this.entityId);
    buf.writeInt(this.field_149444_b.size());

    for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : this.field_149444_b)
    {
        buf.writeString(s20packetentityproperties$snapshot.func_151409_a());
        buf.writeDouble(s20packetentityproperties$snapshot.func_151410_b());
        buf.writeVarIntToBuffer(s20packetentityproperties$snapshot.func_151408_c().size());

        for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c())
        {
            buf.writeUuid(attributemodifier.getID());
            buf.writeDouble(attributemodifier.getAmount());
            buf.writeByte(attributemodifier.getOperation());
        }
    }
}
项目:BaseClient    文件:SharedMonsterAttributes.java   
private static void applyModifiersToAttributeInstance(IAttributeInstance p_111258_0_, NBTTagCompound p_111258_1_)
{
    p_111258_0_.setBaseValue(p_111258_1_.getDouble("Base"));

    if (p_111258_1_.hasKey("Modifiers", 9))
    {
        NBTTagList nbttaglist = p_111258_1_.getTagList("Modifiers", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.getCompoundTagAt(i));

            if (attributemodifier != null)
            {
                AttributeModifier attributemodifier1 = p_111258_0_.getModifier(attributemodifier.getID());

                if (attributemodifier1 != null)
                {
                    p_111258_0_.removeModifier(attributemodifier1);
                }

                p_111258_0_.applyModifier(attributemodifier);
            }
        }
    }
}
项目:BaseClient    文件:S20PacketEntityProperties.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.entityId = buf.readVarIntFromBuffer();
    int i = buf.readInt();

    for (int j = 0; j < i; ++j)
    {
        String s = buf.readStringFromBuffer(64);
        double d0 = buf.readDouble();
        List<AttributeModifier> list = Lists.<AttributeModifier>newArrayList();
        int k = buf.readVarIntFromBuffer();

        for (int l = 0; l < k; ++l)
        {
            UUID uuid = buf.readUuid();
            list.add(new AttributeModifier(uuid, "Unknown synced attribute modifier", buf.readDouble(), buf.readByte()));
        }

        this.field_149444_b.add(new S20PacketEntityProperties.Snapshot(s, d0, list));
    }
}
项目:Loot-Slash-Conquer    文件:ItemGeneratorHelper.java   
/**
 * Helper method for writing new attribute modifiers.
 * @param attribute
 * @param modifier
 * @param slot
 * @return
 */
public static NBTTagCompound writeAttributeModifierToNBT(IAttribute attribute, AttributeModifier modifier, EntityEquipmentSlot slot) 
{
    NBTTagCompound nbt = new NBTTagCompound();

    nbt.setString("AttributeName", attribute.getName());
    nbt.setString("Name", modifier.getName());
    nbt.setString("Slot", slot.getName());
    nbt.setDouble("Amount", modifier.getAmount());
    nbt.setInteger("Operation", modifier.getOperation());
    nbt.setLong("UUIDMost", modifier.getID().getMostSignificantBits());
    nbt.setLong("UUIDLeast", modifier.getID().getLeastSignificantBits());

    return nbt;
}
项目:Loot-Slash-Conquer    文件:EventEntityJoinWorld.java   
public static void setAttributeModifiers(EntityLivingBase entity, int level)
{
    AttributeModifier attackDamage = new AttributeModifier(ATTACK_DAMAGE, "attackDamage", level * 0.1, 1);
    AttributeModifier maxHealth = new AttributeModifier(MAX_HEALTH, "maxHealth", level * 0.2, 1);

    if (!entity.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).hasModifier(attackDamage))
        entity.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).applyModifier(attackDamage);

    if (!entity.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).hasModifier(maxHealth))
    {
        entity.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(maxHealth);
        entity.setHealth(entity.getMaxHealth());
    }
}
项目:Loot-Slash-Conquer    文件:ItemLEAdvancedMelee.java   
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) 
{
    final Multimap<String, AttributeModifier> modifiers = super.getAttributeModifiers(slot, stack);

    if (slot == EntityEquipmentSlot.MAINHAND) 
    {
        replaceModifier(modifiers, SharedMonsterAttributes.ATTACK_DAMAGE, ATTACK_DAMAGE_MODIFIER, damageMultiplier);
        replaceModifier(modifiers, SharedMonsterAttributes.ATTACK_SPEED, ATTACK_SPEED_MODIFIER, speedMultiplier);
    }

    return modifiers;
}
项目:Loot-Slash-Conquer    文件:ItemLEAdvancedMelee.java   
/**
 * Replace a modifier in the {@link Multimap} with a copy that's had {@code multiplier} applied to its value.
 *
 * @param modifierMultimap The MultiMap
 * @param attribute        The attribute being modified
 * @param id               The ID of the modifier
 * @param multiplier       The multiplier to apply
 */
private void replaceModifier(Multimap<String, AttributeModifier> modifierMultimap, IAttribute attribute, UUID id, double multiplier) 
{
    // Get the modifiers for the specified attribute
    final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getName());
    // Find the modifier with the specified ID, if any
    final Optional<AttributeModifier> modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst();

    if (modifierOptional.isPresent()) // If it exists,
    {
        final AttributeModifier modifier = modifierOptional.get();
        modifiers.remove(modifier); // Remove it
        modifiers.add(new AttributeModifier(modifier.getID(), modifier.getName(), modifier.getAmount() * multiplier, modifier.getOperation())); // Add the new modifier
    }
}
项目:HeroUtils    文件:CraftingRegistry.java   
public void unregister() {
    Iterator<IRecipe> it = CraftingManager.getInstance().getRecipeList().iterator();

    while (it.hasNext()) {
        IRecipe recipe = it.next();
        ItemStack output = recipe.getRecipeOutput();
        if (output != null && output.getItem() != null) {
            if (output.isItemEqual(new ItemStack(Items.IRON_SWORD))){
                output.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 20, 0), EntityEquipmentSlot.MAINHAND);
                output.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 6, 0), EntityEquipmentSlot.MAINHAND);
            }
            if (output.isItemEqual(new ItemStack(Items.GOLDEN_SWORD))){
                output.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 20, 0), EntityEquipmentSlot.MAINHAND);
                output.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 5, 0), EntityEquipmentSlot.MAINHAND);
            }
            if (output.isItemEqual(new ItemStack(Items.DIAMOND_SWORD))){
                output.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 20, 0), EntityEquipmentSlot.MAINHAND);
                output.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 8, 0), EntityEquipmentSlot.MAINHAND);
            }
            if (output.isItemEqual(new ItemStack(Items.WOODEN_SWORD))){
                output.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 20, 0), EntityEquipmentSlot.MAINHAND);
                output.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 4, 0), EntityEquipmentSlot.MAINHAND);
            }
            if (output.isItemEqual(new ItemStack(Items.STONE_SWORD))){
                output.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 20, 0), EntityEquipmentSlot.MAINHAND);
                output.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 5, 0), EntityEquipmentSlot.MAINHAND);
            }
        }
    }
}
项目:Adventurers-Toolbox    文件:ItemRock.java   
@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", (double) 3.0F, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(),
                new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double) -3F, 0));
    }

    return multimap;
}
项目:Mods    文件:ItemParachute.java   
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(slot, stack);

    if (slot == EntityEquipmentSlot.CHEST) {
        multimap.put(SharedMonsterAttributes.ARMOR.getName(),
                new AttributeModifier(UUID.fromString("D8499B04-0E66-4726-AB29-64469D234E0D"), "Armor modifier", getData(stack).getFloat(PropertyType.ARMOR), 0));
        multimap.put(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName(),
                new AttributeModifier(UUID.fromString("D8499B04-0E66-4726-AB29-64469D234AB7"),
                        "Armor toughness modifier", getData(stack).getFloat(PropertyType.ARMOR_TOUGHNESS), 0));
    }

    return multimap;
}
项目:Thermionics    文件:ItemBlockEquivalentState.java   
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    if (block instanceof IArmor) {
        return ((IArmor)block).getAttributeModifiers(slot,stack);
    } else {
        return super.getAttributeModifiers(slot, stack);
    }
}
项目:Mob-Option-Redux    文件:Stats.java   
protected AttributeModifier createModifier(String type) {
    if (type.equals("health"))
        return new AttributeModifier(MODIFIER_HEALTH_ID, MODIFIER_HEALTH_NAME, getBonusMaxHealth(), 0);

    if (type.equals("attack"))
        return new AttributeModifier(MODIFIER_ATTACK_ID, MODIFIER_ATTACK_NAME, getBonusMaxAttack(), 0);

    if (type.equals("follow"))
        return new AttributeModifier(MODIFIER_FOLLOW_ID, MODIFIER_FOLLOW_NAME, getBonusFollowRange(), 0);

    return null;
}
项目:Backmemed    文件:NetHandlerPlayClient.java   
/**
 * Updates en entity's attributes and their respective modifiers, which are used for speed bonusses (player
 * sprinting, animals fleeing, baby speed), weapon/tool attackDamage, hostiles followRange randomization, zombie
 * maxHealth and knockback resistance as well as reinforcement spawning chance.
 */
public void handleEntityProperties(SPacketEntityProperties packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

    if (entity != null)
    {
        if (!(entity instanceof EntityLivingBase))
        {
            throw new IllegalStateException("Server tried to update attributes of a non-living entity (actually: " + entity + ")");
        }
        else
        {
            AbstractAttributeMap abstractattributemap = ((EntityLivingBase)entity).getAttributeMap();

            for (SPacketEntityProperties.Snapshot spacketentityproperties$snapshot : packetIn.getSnapshots())
            {
                IAttributeInstance iattributeinstance = abstractattributemap.getAttributeInstanceByName(spacketentityproperties$snapshot.getName());

                if (iattributeinstance == null)
                {
                    iattributeinstance = abstractattributemap.registerAttribute(new RangedAttribute((IAttribute)null, spacketentityproperties$snapshot.getName(), 0.0D, 2.2250738585072014E-308D, Double.MAX_VALUE));
                }

                iattributeinstance.setBaseValue(spacketentityproperties$snapshot.getBaseValue());
                iattributeinstance.removeAllModifiers();

                for (AttributeModifier attributemodifier : spacketentityproperties$snapshot.getModifiers())
                {
                    iattributeinstance.applyModifier(attributemodifier);
                }
            }
        }
    }
}
项目:harshencastle    文件:ElementalPendant.java   
@Override
public void onAdd(EntityPlayer player, int slot) {
    IAttributeInstance attributeHealth = player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH);
    AttributeModifier modifierHealth = new AttributeModifier(UUID.fromString("d20525ee-98b2-402f-b298-61bc19a9e0c5"), "elementalPendantHealth4", 4, 0).setSaved(true);
    if(!attributeHealth.hasModifier(modifierHealth))    
        attributeHealth.applyModifier(modifierHealth);

    IAttributeInstance attributeArmour = player.getEntityAttribute(SharedMonsterAttributes.ARMOR);
    AttributeModifier modifierArmour = new AttributeModifier(UUID.fromString("82b79e32-3c85-4132-b121-03807793338c"), "elementalPendantArmour2", 2, 0).setSaved(true);
    if(!attributeArmour.hasModifier(modifierArmour))    
        attributeArmour.applyModifier(modifierArmour);
}
项目:TrustCircle    文件:PotionTrust.java   
@Override
public double getAttributeModifierAmount(int amplifier, AttributeModifier modifier){
    if(TrustCircle.baseStrength > 0){
        return TrustCircle.baseStrength*(amplifier+1);
    }
    else{
        return super.getAttributeModifierAmount(amplifier, modifier);
    }
}
项目:Backmemed    文件:ItemArmor.java   
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
{
    Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);

    if (equipmentSlot == this.armorType)
    {
        multimap.put(SharedMonsterAttributes.ARMOR.getAttributeUnlocalizedName(), new AttributeModifier(ARMOR_MODIFIERS[equipmentSlot.getIndex()], "Armor modifier", (double)this.damageReduceAmount, 0));
        multimap.put(SharedMonsterAttributes.ARMOR_TOUGHNESS.getAttributeUnlocalizedName(), new AttributeModifier(ARMOR_MODIFIERS[equipmentSlot.getIndex()], "Armor toughness", (double)this.toughness, 0));
    }

    return multimap;
}
项目:Backmemed    文件:Potion.java   
public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, AbstractAttributeMap attributeMapIn, int amplifier)
{
    for (Entry<IAttribute, AttributeModifier> entry : this.attributeModifierMap.entrySet())
    {
        IAttributeInstance iattributeinstance = attributeMapIn.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
        }
    }
}
项目:Adventurers-Toolbox    文件:ItemATMace.java   
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot,
        ItemStack stack) {
    Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();

    if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER,
                "Weapon modifier", (double) 8.5F + this.getAttackDamage(stack), 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(),
                new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double) (-3.4F + ((getEfficiency(stack) / 2.7F) * 0.125F)), 0));
    }

    return multimap;
}
项目:Thermionics    文件:BlockPotStill.java   
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    Multimap<String, AttributeModifier> modifiers = HashMultimap.create();
    if (slot==EntityEquipmentSlot.HEAD) {
        modifiers.put(
                SharedMonsterAttributes.ARMOR.getName(),
                new AttributeModifier(UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150"), "Armor modifier", 3D, 0)
                );

    }

    return modifiers;
}
项目:DecompiledMinecraft    文件:ItemStack.java   
public Multimap<String, AttributeModifier> getAttributeModifiers()
{
    Multimap<String, AttributeModifier> multimap;

    if (this.hasTagCompound() && this.stackTagCompound.hasKey("AttributeModifiers", 9))
    {
        multimap = HashMultimap.<String, AttributeModifier>create();
        NBTTagList nbttaglist = this.stackTagCompound.getTagList("AttributeModifiers", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            AttributeModifier attributemodifier = SharedMonsterAttributes.readAttributeModifierFromNBT(nbttagcompound);

            if (attributemodifier != null && attributemodifier.getID().getLeastSignificantBits() != 0L && attributemodifier.getID().getMostSignificantBits() != 0L)
            {
                multimap.put(nbttagcompound.getString("AttributeName"), attributemodifier);
            }
        }
    }
    else
    {
        multimap = this.getItem().getItemAttributeModifiers();
    }

    return multimap;
}
项目:Mods    文件:EntityDemoman.java   
@Override
public IEntityLivingData onInitialSpawn(DifficultyInstance p_180482_1_, IEntityLivingData data) {
    data=super.onInitialSpawn(p_180482_1_, data);
    if(!this.loadout.getStackInSlot(1).isEmpty() && this.loadout.getStackInSlot(1).getItem() instanceof ItemChargingTarge){
        this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("ShieldHP", 3, 0));
        this.heal(3);
        this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).applyModifier(new AttributeModifier("ShieldMove", 0.02, 2));
    }
    return data;
}
项目:DecompiledMinecraft    文件:Potion.java   
public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, BaseAttributeMap p_111187_2_, int amplifier)
{
    for (Entry<IAttribute, AttributeModifier> entry : this.attributeModifierMap.entrySet())
    {
        IAttributeInstance iattributeinstance = p_111187_2_.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
        }
    }
}
项目:AdvancedCombat    文件:ArmorHandler.java   
/** Handle wearing nether fortress armor */
private boolean netherFortressArmor(LivingHurtEvent e) {
    EntityLivingBase hurt = e.getEntityLiving();

    // do things based on the armor status
    int armorCount = getWearingSetCount(hurt, ItemArmorNether.class);
    if(armorCount > 0) {

        // knockback resistance
        IAttributeInstance inst = hurt.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE);
        AttributeModifier mod = new AttributeModifier(knockbackID, "nfakb", armorCount / 4D, 0).setSaved(false);
        if(inst.getModifier(knockbackID) == null) inst.applyModifier(mod);

        // wither thorns
        if(e.getSource().getTrueSource() != null && e.getSource().getTrueSource() instanceof EntityLivingBase) {
            EntityLivingBase attacker = (EntityLivingBase)e.getSource().getTrueSource();
            attacker.addPotionEffect(new PotionEffect(MobEffects.WITHER, armorCount * 20, armorCount > 2 ? 1 : 0));
        }

        // blast resistance I
        if(e.getSource().isExplosion()) {
            e.setAmount(e.getAmount() * (1 - armorCount / 8F));
        }

        return true;
    }
    return false;
}
项目:DecompiledMinecraft    文件:SharedMonsterAttributes.java   
/**
 * Creates an NBTTagCompound from an AttributeModifier
 */
private static NBTTagCompound writeAttributeModifierToNBT(AttributeModifier p_111262_0_)
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    nbttagcompound.setString("Name", p_111262_0_.getName());
    nbttagcompound.setDouble("Amount", p_111262_0_.getAmount());
    nbttagcompound.setInteger("Operation", p_111262_0_.getOperation());
    nbttagcompound.setLong("UUIDMost", p_111262_0_.getID().getMostSignificantBits());
    nbttagcompound.setLong("UUIDLeast", p_111262_0_.getID().getLeastSignificantBits());
    return nbttagcompound;
}
项目:CustomWorldGen    文件:SharedMonsterAttributes.java   
/**
 * Creates an NBTTagCompound from an AttributeModifier
 */
public static NBTTagCompound writeAttributeModifierToNBT(AttributeModifier modifier)
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    nbttagcompound.setString("Name", modifier.getName());
    nbttagcompound.setDouble("Amount", modifier.getAmount());
    nbttagcompound.setInteger("Operation", modifier.getOperation());
    nbttagcompound.setUniqueId("UUID", modifier.getID());
    return nbttagcompound;
}
项目:DecompiledMinecraft    文件:SharedMonsterAttributes.java   
/**
 * Creates an AttributeModifier from an NBTTagCompound
 */
public static AttributeModifier readAttributeModifierFromNBT(NBTTagCompound p_111259_0_)
{
    UUID uuid = new UUID(p_111259_0_.getLong("UUIDMost"), p_111259_0_.getLong("UUIDLeast"));

    try
    {
        return new AttributeModifier(uuid, p_111259_0_.getString("Name"), p_111259_0_.getDouble("Amount"), p_111259_0_.getInteger("Operation"));
    }
    catch (Exception exception)
    {
        logger.warn("Unable to create attribute: " + exception.getMessage());
        return null;
    }
}