@Override public void removeCitizen(final CitizenData citizen) { if (citizen != null) { final Optional<EntityCitizen> optCitizen = citizen.getCitizenEntity(); if (optCitizen.isPresent()) { optCitizen.get().removeAllHealthModifiers(); optCitizen.get().getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(SharedMonsterAttributes.ARMOR.getDefaultValue()); } } super.removeCitizen(citizen); }
/** * Add exhaustion * * @param amount * @param ignoreModifier If the entity exhaustion attribute {@link VReference#bloodExhaustion} should be ignored */ void addExhaustion(float amount, boolean ignoreModifier) { VampirePlayer.get(player).checkAttributes(VReference.bloodExhaustion); IAttributeInstance attribute = player.getEntityAttribute(VReference.bloodExhaustion); float mult; if (ignoreModifier) { mult = 1F; } else { if (attribute == null) { //Probably not needed anymore TODO remove VampirismMod.log.w(TAG, "Blood exhaustion attribute is null for player %s (%s)", player, player == null ? null : player.getAttributeMap()); mult = (float) VReference.bloodExhaustion.getDefaultValue(); } else { mult = (float) attribute.getAttributeValue(); } } this.bloodExhaustionLevel = Math.min(bloodExhaustionLevel + amount * mult, 40F); }
@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; }