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

项目: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;
}
项目: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;
}
项目:BaseClient    文件: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;
}
项目:BaseClient    文件: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    文件: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 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;
}
项目:PopularMMOS-EpicProportions-Mod    文件:PotionLoader.java   
public void applyAttributesModifiersToEntity(EntityLivingBase p_111185_1_, BaseAttributeMap p_111185_2_, int p_111185_3_)
{
    Iterator iterator = this.field_111188_I.entrySet().iterator();

    while (iterator.hasNext())
    {
        Entry entry = (Entry)iterator.next();
        IAttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
            iattributeinstance.removeModifier(attributemodifier);
            iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + p_111185_3_, this.func_111183_a(p_111185_3_, attributemodifier), attributemodifier.getOperation()));
        }
    }
}
项目:Cyclic    文件:ReflectionRegistry.java   
public static void register() {
  for (Field f : AbstractHorse.class.getDeclaredFields()) {
    try {
      if (f.getName().equals("JUMP_STRENGTH") || f.getName().equals("field_110270_bw") || "interface net.minecraft.entity.ai.attributes.IAttribute".equals(f.getType() + "")) {
        f.setAccessible(true);
        // save pointer to the obj so we can reference it later
        horseJumpStrength = (IAttribute) f.get(null);
        break;
      }
    }
    catch (Exception e) {
      ModCyclic.logger.error("Severe error, please report this to the mod author [ JUMP_STRENGTH ]:");
      ModCyclic.logger.error(e.getStackTrace().toString());
    }
  }
  if (horseJumpStrength == null) {
    ModCyclic.logger.error(Const.MODID + ": JUMP_STRENGTH : Error - field not found using reflection");
  }
}
项目:Resilience-Client-Source    文件:Potion.java   
public void applyAttributesModifiersToEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3)
{
    Iterator var4 = this.field_111188_I.entrySet().iterator();

    while (var4.hasNext())
    {
        Entry var5 = (Entry)var4.next();
        IAttributeInstance var6 = par2BaseAttributeMap.getAttributeInstance((IAttribute)var5.getKey());

        if (var6 != null)
        {
            AttributeModifier var7 = (AttributeModifier)var5.getValue();
            var6.removeModifier(var7);
            var6.applyModifier(new AttributeModifier(var7.getID(), this.getName() + " " + par3, this.func_111183_a(par3, var7), var7.getOperation()));
        }
    }
}
项目:ExpandedRailsMod    文件: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;
}
项目:Cauldron    文件:Potion.java   
public void applyAttributesModifiersToEntity(EntityLivingBase p_111185_1_, BaseAttributeMap p_111185_2_, int p_111185_3_)
{
    Iterator iterator = this.field_111188_I.entrySet().iterator();

    while (iterator.hasNext())
    {
        Entry entry = (Entry)iterator.next();
        IAttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
            iattributeinstance.removeModifier(attributemodifier);
            iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + p_111185_3_, this.func_111183_a(p_111185_3_, attributemodifier), attributemodifier.getOperation()));
        }
    }
}
项目:Cauldron    文件:Potion.java   
public void applyAttributesModifiersToEntity(EntityLivingBase p_111185_1_, BaseAttributeMap p_111185_2_, int p_111185_3_)
{
    Iterator iterator = this.field_111188_I.entrySet().iterator();

    while (iterator.hasNext())
    {
        Entry entry = (Entry)iterator.next();
        IAttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
            iattributeinstance.removeModifier(attributemodifier);
            iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + p_111185_3_, this.func_111183_a(p_111185_3_, attributemodifier), attributemodifier.getOperation()));
        }
    }
}
项目: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    文件: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
    }
}
项目:Bewitchment    文件:BrewAtributeModifier.java   
public void applyAttributeModifiers(AbstractAttributeMap attributeMap, int amplifier) {
    for (Map.Entry<IAttribute, AttributeModifier> entry : modifierMap.entrySet()) {
        IAttributeInstance attribute = attributeMap.getAttributeInstance(entry.getKey());
        if (attribute == null) continue;

        AttributeModifier modifier = entry.getValue();
        attribute.removeModifier(modifier);
        attribute.applyModifier(new AttributeModifier(modifier.getID(), this.getName() + " " + amplifier, modifier.getAmount() * (double) (amplifier + 1), modifier.getOperation()));
    }
}
项目:Bewitchment    文件:BrewAtributeModifier.java   
public void removeAttributeModifiers(AbstractAttributeMap attributeMapIn, int amplifier) {
    for (Map.Entry<IAttribute, AttributeModifier> entry : modifierMap.entrySet()) {
        IAttributeInstance attribute = attributeMapIn.getAttributeInstance(entry.getKey());
        if (attribute == null) continue;

        attribute.removeModifier(entry.getValue());
    }
}
项目:harshencastle    文件:BaseHarshenScythe.java   
private void replaceModifier(Multimap<String, AttributeModifier> modifierMultimap, IAttribute attribute, UUID id, double multiplier) {

        final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getName());
        final Optional<AttributeModifier> modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst();

        if (modifierOptional.isPresent()) {
            final AttributeModifier modifier = modifierOptional.get();
            modifiers.remove(modifier);
            modifiers.add(new AttributeModifier(modifier.getID(), modifier.getName(), modifier.getAmount() * multiplier, modifier.getOperation()));
        }
    }
项目:ForgeHax    文件:HorseStats.java   
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
    if (EntityUtils.isDrivenByPlayer(event.getEntity()) && getRidingEntity() instanceof AbstractHorse) {

        IAttribute JUMP_STRENGTH = FastReflection.Fields.AbstractHorse_JUMP_STRENGTH.get(getRidingEntity());
        IAttribute MOVEMENT_SPEED = FastReflection.Fields.SharedMonsterAttributes_MOVEMENT_SPEED.get(getRidingEntity());

        ((EntityLivingBase) getRidingEntity()).getEntityAttribute(JUMP_STRENGTH).setBaseValue(jumpHeight.getAsDouble());
        ((EntityLivingBase) getRidingEntity()).getEntityAttribute(MOVEMENT_SPEED).setBaseValue(speed.getAsDouble());
    }
}
项目:DecompiledMinecraft    文件:Potion.java   
/**
 * Used by potions to register the attribute they modify.
 */
public Potion registerPotionAttributeModifier(IAttribute p_111184_1_, String p_111184_2_, double p_111184_3_, int p_111184_5_)
{
    AttributeModifier attributemodifier = new AttributeModifier(UUID.fromString(p_111184_2_), this.getName(), p_111184_3_, p_111184_5_);
    this.attributeModifierMap.put(p_111184_1_, attributemodifier);
    return this;
}
项目: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());
        }
    }
}
项目:DecompiledMinecraft    文件:Potion.java   
public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, BaseAttributeMap p_111185_2_, int amplifier)
{
    for (Entry<IAttribute, AttributeModifier> entry : this.attributeModifierMap.entrySet())
    {
        IAttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
            iattributeinstance.removeModifier(attributemodifier);
            iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + amplifier, this.getAttributeModifierAmount(amplifier, attributemodifier), attributemodifier.getOperation()));
        }
    }
}
项目:DecompiledMinecraft    文件: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(S20PacketEntityProperties 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
        {
            BaseAttributeMap baseattributemap = ((EntityLivingBase)entity).getAttributeMap();

            for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d())
            {
                IAttributeInstance iattributeinstance = baseattributemap.getAttributeInstanceByName(s20packetentityproperties$snapshot.func_151409_a());

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

                iattributeinstance.setBaseValue(s20packetentityproperties$snapshot.func_151410_b());
                iattributeinstance.removeAllModifiers();

                for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c())
                {
                    iattributeinstance.applyModifier(attributemodifier);
                }
            }
        }
    }
}
项目:DecompiledMinecraft    文件:Potion.java   
/**
 * Used by potions to register the attribute they modify.
 */
public Potion registerPotionAttributeModifier(IAttribute p_111184_1_, String p_111184_2_, double p_111184_3_, int p_111184_5_)
{
    AttributeModifier attributemodifier = new AttributeModifier(UUID.fromString(p_111184_2_), this.getName(), p_111184_3_, p_111184_5_);
    this.attributeModifierMap.put(p_111184_1_, attributemodifier);
    return this;
}
项目: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());
        }
    }
}
项目:DecompiledMinecraft    文件:Potion.java   
public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, BaseAttributeMap p_111185_2_, int amplifier)
{
    for (Entry<IAttribute, AttributeModifier> entry : this.attributeModifierMap.entrySet())
    {
        IAttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
            iattributeinstance.removeModifier(attributemodifier);
            iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + amplifier, this.getAttributeModifierAmount(amplifier, attributemodifier), attributemodifier.getOperation()));
        }
    }
}
项目:BaseClient    文件: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(S20PacketEntityProperties 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
        {
            BaseAttributeMap baseattributemap = ((EntityLivingBase)entity).getAttributeMap();

            for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d())
            {
                IAttributeInstance iattributeinstance = baseattributemap.getAttributeInstanceByName(s20packetentityproperties$snapshot.func_151409_a());

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

                iattributeinstance.setBaseValue(s20packetentityproperties$snapshot.func_151410_b());
                iattributeinstance.removeAllModifiers();

                for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c())
                {
                    iattributeinstance.applyModifier(attributemodifier);
                }
            }
        }
    }
}
项目:BaseClient    文件:Potion.java   
/**
 * Used by potions to register the attribute they modify.
 */
public Potion registerPotionAttributeModifier(IAttribute p_111184_1_, String p_111184_2_, double p_111184_3_, int p_111184_5_)
{
    AttributeModifier attributemodifier = new AttributeModifier(UUID.fromString(p_111184_2_), this.getName(), p_111184_3_, p_111184_5_);
    this.attributeModifierMap.put(p_111184_1_, attributemodifier);
    return this;
}
项目:BaseClient    文件: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());
        }
    }
}
项目:BaseClient    文件:Potion.java   
public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, BaseAttributeMap p_111185_2_, int amplifier)
{
    for (Entry<IAttribute, AttributeModifier> entry : this.attributeModifierMap.entrySet())
    {
        IAttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
            iattributeinstance.removeModifier(attributemodifier);
            iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + amplifier, this.getAttributeModifierAmount(amplifier, attributemodifier), attributemodifier.getOperation()));
        }
    }
}
项目:BaseClient    文件: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(S20PacketEntityProperties 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 {
            BaseAttributeMap baseattributemap = ((EntityLivingBase) entity).getAttributeMap();

            for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d()) {
                IAttributeInstance iattributeinstance = baseattributemap
                        .getAttributeInstanceByName(s20packetentityproperties$snapshot.func_151409_a());

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

                iattributeinstance.setBaseValue(s20packetentityproperties$snapshot.func_151410_b());
                iattributeinstance.removeAllModifiers();

                for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c()) {
                    iattributeinstance.applyModifier(attributemodifier);
                }
            }
        }
    }
}
项目:BaseClient    文件:Potion.java   
/**
 * Used by potions to register the attribute they modify.
 */
public Potion registerPotionAttributeModifier(IAttribute p_111184_1_, String p_111184_2_, double p_111184_3_, int p_111184_5_)
{
    AttributeModifier attributemodifier = new AttributeModifier(UUID.fromString(p_111184_2_), this.getName(), p_111184_3_, p_111184_5_);
    this.attributeModifierMap.put(p_111184_1_, attributemodifier);
    return this;
}
项目:BaseClient    文件: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());
        }
    }
}
项目:BaseClient    文件:Potion.java   
public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, BaseAttributeMap p_111185_2_, int amplifier)
{
    for (Entry<IAttribute, AttributeModifier> entry : this.attributeModifierMap.entrySet())
    {
        IAttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
            iattributeinstance.removeModifier(attributemodifier);
            iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + amplifier, this.getAttributeModifierAmount(amplifier, attributemodifier), attributemodifier.getOperation()));
        }
    }
}
项目:UniversalRemote    文件:EntityPlayerMPProxy.java   
@Override
public IAttributeInstance getEntityAttribute(IAttribute attribute) {
    if (m_realPlayer == null) {
        return super.getEntityAttribute(attribute);
    } else {
        syncToRealPlayer();
        return syncPublicFieldsFromRealAndReturn(m_realPlayer.getEntityAttribute(attribute));
    }
}
项目:UniversalRemote    文件:EntityPlayerProxy.java   
@Override
public IAttributeInstance getEntityAttribute(IAttribute attribute) {
    if (m_realPlayer == null) {
        return super.getEntityAttribute(attribute);
    } else {
        return m_realPlayer.getEntityAttribute(attribute);
    }
}
项目:Zombe-Modpack    文件: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);
                }
            }
        }
    }
}
项目: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);
                }
            }
        }
    }
}
项目:Backmemed    文件:Potion.java   
/**
 * Used by potions to register the attribute they modify.
 */
public Potion registerPotionAttributeModifier(IAttribute attribute, String uniqueId, double ammount, int operation)
{
    AttributeModifier attributemodifier = new AttributeModifier(UUID.fromString(uniqueId), this.getName(), ammount, operation);
    this.attributeModifierMap.put(attribute, attributemodifier);
    return this;
}
项目: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());
        }
    }
}
项目:Backmemed    文件:Potion.java   
public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, AbstractAttributeMap attributeMapIn, int amplifier)
{
    for (Entry<IAttribute, AttributeModifier> entry : this.attributeModifierMap.entrySet())
    {
        IAttributeInstance iattributeinstance = attributeMapIn.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
            iattributeinstance.removeModifier(attributemodifier);
            iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + amplifier, this.getAttributeModifierAmount(amplifier, attributemodifier), attributemodifier.getOperation()));
        }
    }
}