movementSpeed.applyModifier(new AttributeModifier("Ermergerd Virus D:", movementSpeed.getBaseValue(), 0)); health.applyModifier(new AttributeModifier("Ermergerd Virus D:", health.getBaseValue(), 0)); jumpHeight.applyModifier(new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, 0));
private void applyModifiers() { removeModifiers(); horse.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).applyModifier(moveSpeedModifier); horse.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(followRangeModifier); }
@Override public void onEnable(EntityTameableDragon dragon) { dragon.getAttributeMap().getAttributeInstance(EntityTameableDragon.MOVEMENT_SPEED_AIR).applyModifier(MODIFIER); }
@Override public IEntityLivingData onInitialSpawn(@Nonnull DifficultyInstance di, @Nullable IEntityLivingData livingData) { spawned = true; // From base entity living class getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", rand.nextGaussian() * 0.05D, 1)); setCombatTaskReal(); addRandomArmor(); setEnchantmentBasedOnDifficulty(di); float f = di.getClampedAdditionalDifficulty(); this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * f); setCanPickUpLoot(rand.nextFloat() < 0.55F * f); setCanBreakDoors(rand.nextFloat() < f * 0.1F); return livingData; }
@Override public void setAttackTarget(@Nullable EntityLivingBase entitylivingbaseIn) { super.setAttackTarget(entitylivingbaseIn); IAttributeInstance iattributeinstance = getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); if (entitylivingbaseIn == null) { targetChangeTime = 0; this.dataManager.set(SCREAMING, Boolean.valueOf(false)); iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST); } else { targetChangeTime = ticksExisted; this.dataManager.set(SCREAMING, Boolean.valueOf(true)); if (!iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST)) { iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST); } } }
@Override public void setAttackTarget(@Nullable EntityLivingBase entitylivingbaseIn) { super.setAttackTarget(entitylivingbaseIn); IAttributeInstance iattributeinstance = getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); if (entitylivingbaseIn == null) { targetChangeTime = 0; this.dataManager.set(SCREAMING, Boolean.valueOf(false)); iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST); } else { targetChangeTime = ticksExisted; this.dataManager.set(SCREAMING, Boolean.valueOf(true)); if (!iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST)) { iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST); } } }
public void setChild (boolean isChild) { this.getDataManager().set(IS_CHILD, Boolean.valueOf(isChild)); if (this.world != null && !this.world.isRemote) { final IAttributeInstance speed = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); speed.removeModifier(BABY_SPEED_BOOST); if (isChild) { speed.applyModifier(BABY_SPEED_BOOST); } } this.setChildSize(isChild); } }
protected void updateAttackDamage(float growthRatio) { IAttributeInstance att = EntityUtil.removeModifier(this, SharedMonsterAttributes.ATTACK_DAMAGE, ATTACK_BOOST_MOD_UID); if (growthRatio == 0 || att == null) { return; } double damageInc = EntityUtil.isHardDifficulty(world) ? ZooConfig.witherCatAttackDamageBonusHard.get() : 0; double attackDif = damageInc + ZooConfig.witherCatAttackDamageBonusAngry.get(); double toAdd = attackDif * growthRatio; AttributeModifier mod = new AttributeModifier(ATTACK_BOOST_MOD_UID, "Transformed Attack Modifier", toAdd, 0); att.applyModifier(mod); }
/** * Called between {@link #beforeFluidWalk(EntityPlayer)} and {@link #afterFluidWalk(EntityPlayer)}. * <p> * Called if the player is currently above a block of the {@link #requiredMaterial}. It is used to actually perform * the operations needed to simulate walking on the fluid. * <p> * The default implementation sets the player's Y motion value (if they are jumping), applies the {@link #modifier}, * and drains steam from the player's {@link eiteam.esteemedinnovation.api.SteamChargable} armor. * @param player The player wearing the coatings. * @param attributes The current movement speed attributes this player has. */ protected void handleFluidWalk(EntityPlayer player, IAttributeInstance attributes) { boolean isJumping = false; try { isJumping = ReflectionHelper.getIsEntityJumping(player); } catch (IllegalAccessException e) { e.printStackTrace(); } player.motionY = isJumping ? 0.5D : 0; attributes.applyModifier(modifier); ItemStack chargable = ChargableUtility.findFirstChargableArmor(player); if (chargable != null) { ChargableUtility.drainSteam(chargable, getConsumption(), player); } }
@Override public boolean assignCitizen(final CitizenData citizen) { // Only change HP values if assign successful if (super.assignCitizen(citizen) && citizen != null) { final Optional<EntityCitizen> optCitizen = citizen.getCitizenEntity(); if (optCitizen.isPresent()) { final AttributeModifier healthModBuildingHP = new AttributeModifier(GUARD_HEALTH_MOD_BUILDING_NAME, getBonusHealth(), 0); optCitizen.get().increaseHPForGuards(); optCitizen .get() .getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH) .applyModifier(healthModBuildingHP); optCitizen .get() .getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH) .applyModifier(healthModConfig); optCitizen .get() .getEntityAttribute(SharedMonsterAttributes.ARMOR) .setBaseValue(SharedMonsterAttributes.ARMOR.getDefaultValue() + getDefenceBonus()); } return true; } return false; }
private void applyScaleModifier(IAttribute attribute) { IAttributeInstance instance = dragon.getEntityAttribute(attribute); AttributeModifier oldModifier = instance.getModifier(DragonScaleModifier.ID); if (oldModifier != null) { instance.removeModifier(oldModifier); } instance.applyModifier(new DragonScaleModifier(getScale())); }
public static void setMaxHealth(EntityLivingBase living, double max) { IAttributeInstance healthAttribute = living.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH); double amount = max - healthAttribute.getBaseValue(); AttributeModifier modifier = healthAttribute.getModifier(HEALTH_MODIFIER_ID); // Need to remove modifier to apply a new one if (modifier != null) { healthAttribute.removeModifier(modifier); } // Operation 0 is a flat increase modifier = new AttributeModifier(HEALTH_MODIFIER_ID, HEALTH_MODIFIER_NAME, amount, 0); healthAttribute.applyModifier(modifier); }
/** * @param player The player to be modified * @param attribute The attribute to be modified * @param name the name of the modifier * @param level the player level * @param lcap the level cap of the modifier * @param max the max modifier value * @param type the exponent used to calculate the actual value depending on level, levelcap and max value * @param operation The operation applied to the attribute * @param evenIntOnly If the modifier should be rounded to an even integer TODO maybe move this */ public static void applyModifier(EntityPlayer player, IAttribute attribute, String name, int level, int lcap, double max, double type, int operation, boolean evenIntOnly) { UUID mod = modifiers.get(attribute); if (mod == null) { VampirismMod.log.w(TAG, "Cannot modify %s, no modifier is registered", attribute); return; } double m = calculateModifierValue(level, lcap, max, type); IAttributeInstance instance = player.getEntityAttribute(attribute); rmMod(instance, mod); if (evenIntOnly) { m = Math.round(m / 2) * 2; } instance.applyModifier(new AttributeModifier(mod, (attribute.getName() + " " + name + " Boost"), m, operation)); }
private static void setModifiers(@Nonnull EntityPlayer player) { SpeedUpgrade speedUpgrade = getActiveSpeedUpgrade(player); if (speedUpgrade != null) { EnergyUpgrade energyUpgrade = getActiveEnergyUpgrade(player); if (energyUpgrade != null) { IAttributeInstance moveInst = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED); AttributeModifier modifier = DarkSteelAttributeModifiers.getWalkSpeed(player.isSprinting(), speedUpgrade.getLevel(), energyUpgrade.getLevel()); moveInst.applyModifier(modifier); } } }
protected void updateHealth(float growthRatio) { IAttributeInstance att = EntityUtil.removeModifier(this, SharedMonsterAttributes.MAX_HEALTH, HEALTH_BOOST_MOD_UID); if (growthRatio == 0 || att == null) { return; } double currentRatio = getHealth() / getMaxHealth(); double healthDif = ZooConfig.witherCatHealthBonusAngry.get(); double toAdd = healthDif * growthRatio; AttributeModifier mod = new AttributeModifier(HEALTH_BOOST_MOD_UID, "Transformed Attack Modifier", toAdd, 0); att.applyModifier(mod); double newHealth = currentRatio * getMaxHealth(); setHealth((float) newHealth); }
private void manageOutOfPower() { IAttributeInstance speed = player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); if (speed.getModifier(outOfPowerSpeedModifier.getID()) == null) { speed.applyModifier(outOfPowerSpeedModifier); } if (player.world.getWorldTime() % 60 == 0) { androidEffects.updateEffect(EFFECT_GLITCH_TIME, 5); playGlitchSound(this, player.getRNG(), 0.2f); } }
/** * Applies healthmodifiers for Guards based on level */ public void increaseHPForGuards() { if (getCitizenData() != null) { // Remove old mod first removeHealthModifier(GUARD_HEALTH_MOD_LEVEL_NAME); // +1 Heart on levels 6,12,18,25,34,43,54 ... final AttributeModifier healthModLevel = new AttributeModifier(GUARD_HEALTH_MOD_LEVEL_NAME, (int) (getCitizenData().getLevel() / (5.0 + getCitizenData().getLevel() / 20.0) * 2), 0); getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(healthModLevel); } }
optCitizen.get().getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(healthModBuildingHP);
private void setModifier(EntityPlayer player, boolean enabled) { if (enabled) { IAttributeInstance health = player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH); if (health.getModifier(healthModifierUUID) == null) { health.applyModifier(new AttributeModifier(healthModifierUUID, "Bat Health Reduction", -0.9, 2).setSaved(false)); } player.capabilities.allowFlying = true; player.capabilities.isFlying = true; setFlightSpeed(player, (float) Balance.vpa.BAT_FLIGHT_SPEED); player.sendPlayerAbilities(); } else { // Health modifier IAttributeInstance health = player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH); AttributeModifier m = health.getModifier(healthModifierUUID); if (m != null) { health.removeModifier(m); } if (!player.capabilities.isCreativeMode) { player.capabilities.allowFlying = false; } player.capabilities.isFlying = false; setFlightSpeed(player, 0.05F); player.sendPlayerAbilities(); } }
enderminy.setScreaming(true); IAttributeInstance iattributeinstance = enderminy.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); iattributeinstance.applyModifier(EntityEnderminy.getAttackingspeedboostmodifier());