use of com.minecolonies.api.entity.citizen.AbstractEntityCitizen in project minecolonies by Minecolonies.
the class VisitorManager method registerCivilian.
@Override
public void registerCivilian(final AbstractCivilianEntity visitor) {
if (visitor.getCivilianID() == 0 || visitorMap.get(visitor.getCivilianID()) == null) {
visitor.remove();
return;
}
final ICitizenData data = visitorMap.get(visitor.getCivilianID());
final Optional<AbstractEntityCitizen> existingCitizen = data.getEntity();
if (!existingCitizen.isPresent()) {
data.setEntity(visitor);
visitor.setCivilianData(data);
return;
}
if (existingCitizen.get() == visitor) {
return;
}
if (visitor.isAlive()) {
existingCitizen.get().remove();
data.setEntity(visitor);
visitor.setCivilianData(data);
return;
}
visitor.remove();
}
use of com.minecolonies.api.entity.citizen.AbstractEntityCitizen in project minecolonies by Minecolonies.
the class JobHealer method onLevelUp.
@Override
public void onLevelUp() {
if (getCitizen().getEntity().isPresent()) {
final AbstractEntityCitizen worker = getCitizen().getEntity().get();
final AttributeModifier speedModifier = new AttributeModifier(SKILL_BONUS_ADD, getCitizen().getCitizenSkillHandler().getLevel(getCitizen().getWorkBuilding().getModuleMatching(WorkerBuildingModule.class, m -> m.getJobEntry() == getJobRegistryEntry()).getPrimarySkill()) * BONUS_SPEED_PER_LEVEL, AttributeModifier.Operation.ADDITION);
AttributeModifierUtils.addModifier(worker, speedModifier, Attributes.MOVEMENT_SPEED);
}
}
use of com.minecolonies.api.entity.citizen.AbstractEntityCitizen in project minecolonies by Minecolonies.
the class JobKnight method ignoresDamage.
@Override
public boolean ignoresDamage(@NotNull final DamageSource damageSource) {
if (damageSource.isExplosion() && this.getColony().getResearchManager().getResearchEffects().getEffectStrength(SHIELD_USAGE) > 0 && InventoryUtils.findFirstSlotInItemHandlerWith(this.getCitizen().getInventory(), Items.SHIELD) != -1) {
if (!this.getCitizen().getEntity().isPresent()) {
return true;
}
final AbstractEntityCitizen worker = this.getCitizen().getEntity().get();
worker.getCitizenItemHandler().setHeldItem(Hand.OFF_HAND, InventoryUtils.findFirstSlotInItemHandlerWith(this.getCitizen().getInventory(), Items.SHIELD));
worker.startUsingItem(Hand.OFF_HAND);
// Apply the colony Flag to the shield
ItemStack shieldStack = worker.getInventoryCitizen().getHeldItem(Hand.OFF_HAND);
CompoundNBT nbt = shieldStack.getOrCreateTagElement("BlockEntityTag");
nbt.put(TAG_BANNER_PATTERNS, worker.getCitizenColonyHandler().getColony().getColonyFlag());
worker.decreaseSaturationForContinuousAction();
return true;
}
return super.ignoresDamage(damageSource);
}
use of com.minecolonies.api.entity.citizen.AbstractEntityCitizen in project minecolonies by Minecolonies.
the class JobKnight method onLevelUp.
@Override
public void onLevelUp() {
// Bonus Health for knights(gets reset upon Firing)
if (getCitizen().getEntity().isPresent()) {
final AbstractEntityCitizen citizen = getCitizen().getEntity().get();
// +1 Heart every 2 level
final AttributeModifier healthModLevel = new AttributeModifier(GUARD_HEALTH_MOD_LEVEL_NAME, getCitizen().getCitizenSkillHandler().getLevel(Skill.Stamina) + KNIGHT_HP_BONUS, AttributeModifier.Operation.ADDITION);
AttributeModifierUtils.addHealthModifier(citizen, healthModLevel);
}
}
use of com.minecolonies.api.entity.citizen.AbstractEntityCitizen in project minecolonies by Minecolonies.
the class JobLumberjack method onLevelUp.
@Override
public void onLevelUp() {
if (getCitizen().getEntity().isPresent()) {
final AbstractEntityCitizen worker = getCitizen().getEntity().get();
final AttributeModifier speedModifier = new AttributeModifier(SKILL_BONUS_ADD, (getCitizen().getCitizenSkillHandler().getLevel(getCitizen().getWorkBuilding().getModuleMatching(WorkerBuildingModule.class, m -> m.getJobEntry() == this.getJobRegistryEntry()).getSecondarySkill()) / 2.0) * BONUS_SPEED_PER_LEVEL, AttributeModifier.Operation.ADDITION);
AttributeModifierUtils.addModifier(worker, speedModifier, Attributes.MOVEMENT_SPEED);
}
}
Aggregations