public static void setAttributeModifiers(AbstractAttributeMap map, NBTTagList list) { for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); IAttributeInstance iattributeinstance = map.getAttributeInstanceByName(nbttagcompound.getString("Name")); if (iattributeinstance == null) { LOGGER.warn("Ignoring unknown attribute \'{}\'", new Object[] {nbttagcompound.getString("Name")}); } else { applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound); } } }
public static void setAttributeModifiers(AbstractAttributeMap map, NBTTagList list) { for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); IAttributeInstance iattributeinstance = map.getAttributeInstanceByName(nbttagcompound.getString("Name")); if (iattributeinstance != null) { applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound); } else { LOGGER.warn("Ignoring unknown attribute \'{}\'", new Object[] {nbttagcompound.getString("Name")}); } } }
public static void setNbt(AbstractHorse horse, NBTTagCompound nbt) { setName(horse, nbt); EnumHorseType horseType = getHorseType(horse); nbt.setInteger("HorseType", horseType.ordinal()); int variant = 0; if (horseType == EnumHorseType.HORSE) { variant = ((EntityHorse) horse).getHorseVariant(); } nbt.setInteger("Variant", variant); AbstractAttributeMap attrMap = horse.getAttributeMap(); nbt.setDouble("Max Health", attrMap.getAttributeInstanceByName("Max Health").getAttributeValue()); nbt.setDouble("Movement Speed", attrMap.getAttributeInstanceByName("Movement Speed").getAttributeValue()); nbt.setDouble("Jump Strength", attrMap.getAttributeInstanceByName("Jump Strength").getAttributeValue()); }
@Override public void applyAttributesModifiersToEntity(EntityLivingBase entity, AbstractAttributeMap attributeMapIn, int amplifier) { if(this==PotionRegistry.Radiation){ entity.getActivePotionEffect(PotionRegistry.Radiation).getCurativeItems().clear(); } if(this==PotionRegistry.Arsenic){ entity.getActivePotionEffect(PotionRegistry.Arsenic).getCurativeItems().clear(); } if(this==PotionRegistry.Hydrargyrum){ entity.getActivePotionEffect(PotionRegistry.Hydrargyrum).getCurativeItems().clear(); } if(this==PotionRegistry.CarbonMonoxyde){ entity.getActivePotionEffect(PotionRegistry.CarbonMonoxyde).getCurativeItems().clear(); } }
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())); } }
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()); } }
@Override public AbstractAttributeMap getAttributeMap() { if (m_realPlayer == null) { return super.getAttributeMap(); } else { syncToRealPlayer(); return syncPublicFieldsFromRealAndReturn(m_realPlayer.getAttributeMap()); } }
@Override public AbstractAttributeMap getAttributeMap() { if (m_realPlayer == null) { return super.getAttributeMap(); } else { return m_realPlayer.getAttributeMap(); } }
/** * 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); } } } } }
/** * Returns this entity's attribute map (where all its attributes are stored) */ public AbstractAttributeMap getAttributeMap() { if (this.attributeMap == null) { this.attributeMap = new AttributeMap(); } return this.attributeMap; }
/** * Creates an NBTTagList from a BaseAttributeMap, including all its AttributeInstances */ public static NBTTagList writeBaseAttributeMapToNBT(AbstractAttributeMap map) { NBTTagList nbttaglist = new NBTTagList(); for (IAttributeInstance iattributeinstance : map.getAllAttributes()) { nbttaglist.appendTag(writeAttributeInstanceToNBT(iattributeinstance)); } return nbttaglist; }
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()); } } }
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())); } } }
public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, AbstractAttributeMap attributeMapIn, int amplifier) { super.removeAttributesModifiersFromEntity(entityLivingBaseIn, attributeMapIn, amplifier); if (entityLivingBaseIn.getHealth() > entityLivingBaseIn.getMaxHealth()) { entityLivingBaseIn.setHealth(entityLivingBaseIn.getMaxHealth()); } }
@Override public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, @Nonnull AbstractAttributeMap attributeMapIn, int amplifier) { super.applyAttributesModifiersToEntity(entityLivingBaseIn, attributeMapIn, amplifier); entityLivingBaseIn.world.playSound(null, entityLivingBaseIn.getPosition(), ModSounds.ETHEREAL_PASS_BY, SoundCategory.NEUTRAL, 1f, 1); if (!(entityLivingBaseIn instanceof EntityPlayer)) PacketHandler.NETWORK.sendToAll(new PacketVanishPotion(entityLivingBaseIn.getEntityId(), 0, 100)); }
@Override public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, @Nonnull AbstractAttributeMap attributeMapIn, int amplifier) { super.removeAttributesModifiersFromEntity(entityLivingBaseIn, attributeMapIn, amplifier); entityLivingBaseIn.world.playSound(null, entityLivingBaseIn.getPosition(), ModSounds.ETHEREAL_PASS_BY, SoundCategory.NEUTRAL, 1f, 1); if (!(entityLivingBaseIn instanceof EntityPlayer)) PacketHandler.NETWORK.sendToAll(new PacketVanishPotion(entityLivingBaseIn.getEntityId())); }
@Override public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, @Nonnull AbstractAttributeMap attributeMapIn, int amplifier) { CapManager manager = new CapManager(entityLivingBaseIn); manager.setMana(0); manager.setBurnout(manager.getMaxBurnout()); entityLivingBaseIn.addPotionEffect(new PotionEffect(MobEffects.MINING_FATIGUE, 200, 3, true, true)); entityLivingBaseIn.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 200, 3, true, true)); entityLivingBaseIn.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 200, 3, true, true)); entityLivingBaseIn.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 200, 3, true, true)); if (!(entityLivingBaseIn instanceof EntityPlayer) || !((EntityPlayer) entityLivingBaseIn).capabilities.isCreativeMode) entityLivingBaseIn.setHealth(0.5f); super.removeAttributesModifiersFromEntity(entityLivingBaseIn, attributeMapIn, amplifier); }
@Override public void removeAttributesModifiersFromEntity(EntityLivingBase entity, AbstractAttributeMap attributeMap, int amplifier) { IChoke choke = entity.getCapability(ChokeProvider.AIR_CAP, null); choke.setActive(false); updateChoke(entity, choke); super.removeAttributesModifiersFromEntity(entity, attributeMap, amplifier); }
@Override public void applyAttributesModifiersToEntity(EntityLivingBase entity, AbstractAttributeMap attributeMap, int amplifier) { IChoke choke = entity.getCapability(ChokeProvider.AIR_CAP, null); choke.setAir(entity.getAir()); choke.setActive(true); updateChoke(entity, choke); super.applyAttributesModifiersToEntity(entity, attributeMap, amplifier); }
@Override public void removeAttributesModifiersFromEntity(EntityLivingBase entity, AbstractAttributeMap attributeMap, int amplifier) { super.removeAttributesModifiersFromEntity(entity, attributeMap, amplifier); if (amplifier >= 4 && entity instanceof EntityCreature) ((EntityLiving) entity).setNoAI(false); }
@Override public AbstractAttributeMap getAttributeMap() { //null check because super constructor calls this method if(getSettler() == null) { AbstractAttributeMap map = new AttributeMap(); map.registerAttribute(SharedMonsterAttributes.MAX_HEALTH); return map; } else { return getSettler().getAttributeMap(); } }
public AbstractAttributeMap getAttributeMap() { if (this.attributeMap == null) { this.attributeMap = new AttributeMap(); } return this.attributeMap; }
/** * Refresh the attribute map by removing from the old item and applying the current item * @param attributeMap the map to refresh * @param oldItem the old item whose attributes will be removed * @param currentItem the current item whose attributes will be applied */ public static void refreshAttributes(AbstractAttributeMap attributeMap, ItemStack oldItem, ItemStack currentItem) { if(!oldItem.isEmpty()) attributeMap.removeAttributeModifiers(oldItem.getAttributeModifiers(EntityEquipmentSlot.MAINHAND)); if(!currentItem.isEmpty()) attributeMap.applyAttributeModifiers(currentItem.getAttributeModifiers(EntityEquipmentSlot.OFFHAND)); }
/** * Register the custom attributes */ @SubscribeEvent public void onLivingConstructor(EntityEvent.EntityConstructing constructing){ if(constructing.getEntity() instanceof EntityLivingBase){ AbstractAttributeMap attributeMap = ((EntityLivingBase) constructing.getEntity()).getAttributeMap(); attributeMap.registerAttribute(Attributes.armourPenetrate); attributeMap.registerAttribute(Attributes.daze); if(constructing.getEntity() instanceof EntityPlayer){ attributeMap.registerAttribute(Attributes.extendedReach).setBaseValue(-2.2);//Reduce bare hands range } attributeMap.registerAttribute(Attributes.attackSpeed); attributeMap.registerAttribute(Attributes.mountedBonus); } }
public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, AbstractAttributeMap attributeMapIn, int amplifier) { entityLivingBaseIn.setAbsorptionAmount(entityLivingBaseIn.getAbsorptionAmount() - (float)(4 * (amplifier + 1))); super.removeAttributesModifiersFromEntity(entityLivingBaseIn, attributeMapIn, amplifier); }
public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, AbstractAttributeMap attributeMapIn, int amplifier) { entityLivingBaseIn.setAbsorptionAmount(entityLivingBaseIn.getAbsorptionAmount() + (float)(4 * (amplifier + 1))); super.applyAttributesModifiersToEntity(entityLivingBaseIn, attributeMapIn, amplifier); }
@Override public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, AbstractAttributeMap attributeMapIn, int amplifier) { if(tarredBurningEntities.contains(entityLivingBaseIn)) tarredBurningEntities.remove(entityLivingBaseIn); }
@Override public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, @Nonnull AbstractAttributeMap attributeMapIn, int amplifier) { entityLivingBaseIn.getEntityData().setFloat("rot_yaw", entityLivingBaseIn.rotationYaw); entityLivingBaseIn.getEntityData().setFloat("rot_pitch", entityLivingBaseIn.rotationPitch); super.applyAttributesModifiersToEntity(entityLivingBaseIn, attributeMapIn, amplifier); }