private void registerAttributes(EntityPlayer player) { player.getAttributeMap().registerAttribute(AndroidAttributes.attributeGlitchTime); player.getAttributeMap().registerAttribute(AndroidAttributes.attributeBatteryUse); }
AbstractAttributeMap attributes = newHorse.getAttributeMap(); IAttributeInstance movementSpeed = attributes.getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED); movementSpeed.setBaseValue(oldAttributes.getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED).getBaseValue()); movementSpeed.applyModifier(new AttributeModifier("Ermergerd Virus D:", movementSpeed.getBaseValue(), 0)); IAttributeInstance health = attributes.getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH); health.setBaseValue(oldAttributes.getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).getBaseValue()); health.applyModifier(new AttributeModifier("Ermergerd Virus D:", health.getBaseValue(), 0)); IAttributeInstance jumpHeight = attributes.getAttributeInstance(AbstractHorse.JUMP_STRENGTH); jumpHeight.setBaseValue(oldAttributes.getAttributeInstance(AbstractHorse.JUMP_STRENGTH).getBaseValue()); jumpHeight.applyModifier(new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, 0));
@Override public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { if(!player.world.isRemote) { Multimap<String, AttributeModifier> attributes = HashMultimap.create(); fillModifiers(attributes, stack); player.getAttributeMap().applyAttributeModifiers(attributes); } }
private static void handleAttributes(@Nonnull EntityEvent event) { if (event.getEntity() instanceof EntityPlayer) { final AbstractAttributeMap map = ((EntityLivingBase) event.getEntity()).getAttributeMap(); if (NullHelper.untrust(map.getAttributeInstance(AOE_XZ)) == null) { map.registerAttribute(AOE_XZ).setBaseValue(0); map.registerAttribute(AOE_Y).setBaseValue(0); map.registerAttribute(AOE_XYZ).setBaseValue(0); } } }
/** * 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)); }
@Override public void onUnequipped(ItemStack stack, EntityLivingBase player) { if(!player.world.isRemote) { Multimap<String, AttributeModifier> attributes = HashMultimap.create(); fillModifiers(attributes, stack); player.getAttributeMap().removeAttributeModifiers(attributes); } }
private void applyAttribute(NpcBase npc, String attributeName, double baseValue) { IAttributeInstance attribute = npc.getAttributeMap().getAttributeInstanceByName(attributeName); if (attribute != null) { attribute.setBaseValue(baseValue); if (attribute.getAttribute() == SharedMonsterAttributes.MAX_HEALTH) { npc.setHealth((float) baseValue); } } }
private void applyEntityAttributes() { //Checking if already registered, since this method has to be called multiple times due to SpongeForge not recreating the player, but resetting the attribute map if (player.getAttributeMap().getAttributeInstance(VReference.sunDamage) == null) { player.getAttributeMap().registerAttribute(VReference.sunDamage).setBaseValue(Balance.vp.SUNDAMAGE_DAMAGE); } if (player.getAttributeMap().getAttributeInstance(VReference.bloodExhaustion) == null) { player.getAttributeMap().registerAttribute(VReference.bloodExhaustion).setBaseValue(Balance.vp.BLOOD_EXHAUSTION_BASIC_MOD); } if (player.getAttributeMap().getAttributeInstance(VReference.biteDamage) == null) { player.getAttributeMap().registerAttribute(VReference.biteDamage).setBaseValue(Balance.vp.BITE_DMG); } }
public void updateStatModifyers(IBioticStat stat) { int unlockedLevel = getUnlockedLevel(stat); Multimap<String, AttributeModifier> multimap = stat.attributes(this, unlockedLevel); if (multimap != null) { if (isAndroid()) { if (unlockedLevel > 0) { if (stat.isEnabled(this, unlockedLevel)) { player.getAttributeMap().applyAttributeModifiers(multimap); } else { player.getAttributeMap().removeAttributeModifiers(multimap); } } else { player.getAttributeMap().removeAttributeModifiers(multimap); } } else { player.getAttributeMap().removeAttributeModifiers(multimap); } } }
@Override public void onUnequipped(ItemStack stack, EntityLivingBase player) { if(!player.world.isRemote) { Multimap<String, AttributeModifier> attributes = HashMultimap.create(); fillModifiers(attributes, stack); player.getAttributeMap().removeAttributeModifiers(attributes); } }
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(ZooConfig.fallenMountHealth.get()); getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.2); final IAttributeInstance jumpStrength = getAttributeMap().getAttributeInstanceByName("horse.jumpStrength"); if (jumpStrength != null) { jumpStrength.setBaseValue(0.5);
@Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_SPEED); }
default void applyAttributes(@Nonnull EntityLivingBase entity, @Nonnull IValue<Double> baseHealth, @Nonnull IValue<Double> baseAttack) { entity.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(baseHealth.get()); IAttributeInstance ai = entity.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE); if (NullHelper.untrust(ai) == null) { entity.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE); ai = entity.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE); } ai.setBaseValue(baseAttack.get()); }
@Override public void onUpdate() { ItemStack prev = prevWeapon; ItemStack cur = getHeldItemMainhand(); if (!ItemStack.areItemStacksEqual(cur, prev)) { if (!prev.isEmpty()) { getAttributeMap().removeAttributeModifiers(prev.getAttributeModifiers(EntityEquipmentSlot.MAINHAND)); } if (!cur.isEmpty()) { getAttributeMap().applyAttributeModifiers(cur.getAttributeModifiers(EntityEquipmentSlot.MAINHAND)); } prevWeapon = cur.copy(); } if (chargedLocation != null && chargedLocation.chargeItems(new NNList<>(cur))) { killerJoe.markDirty(); } ticksSinceLastSwing++; }
e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP * playerCount); if (hard) e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ARMOR).setBaseValue(15);
private void clearAllStatAttributeModifiers() { for (IBioticStat stat : MatterOverdrive.STAT_REGISTRY.getStats()) { int unlockedLevel = getUnlockedLevel(stat); Multimap<String, AttributeModifier> multimap = stat.attributes(this, unlockedLevel); if (multimap != null) { player.getAttributeMap().removeAttributeModifiers(multimap); } } }
@Override public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { if(!player.world.isRemote) { Multimap<String, AttributeModifier> attributes = HashMultimap.create(); fillModifiers(attributes, stack); player.getAttributeMap().applyAttributeModifiers(attributes); } }
/** * 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); } }
@Override public void onUpdate() { ItemStack itemstack = previousItem; ItemStack itemstack1 = getHeldItem(EnumHand.MAIN_HAND); if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) { if (!itemstack.isEmpty()) { getAttributeMap().removeAttributeModifiers(itemstack.getAttributeModifiers(EntityEquipmentSlot.MAINHAND)); } if (!itemstack1.isEmpty()) { getAttributeMap().applyAttributeModifiers(itemstack1.getAttributeModifiers(EntityEquipmentSlot.MAINHAND)); } myName = "[CoFH]" + (!itemstack1.isEmpty() ? " using " + itemstack1.getDisplayName() : ""); } previousItem = itemstack1.isEmpty() ? ItemStack.EMPTY : itemstack1.copy(); interactionManager.updateBlockRemoving(); //This was commented out beforehand fyi. //if (itemInUse != null) { // tickItemInUse(itemstack); //} }
protected double getFollowRange() { return dragon.getAttributeMap().getAttributeInstance(FOLLOW_RANGE) .getAttributeValue(); } }