use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.
the class RestartCitizenMessage method onExecute.
@Override
protected void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer, final IColony colony) {
final ServerPlayerEntity player = ctxIn.getSender();
if (player == null) {
return;
}
final ICitizenData citizen = colony.getCitizenManager().getCivilian(citizenID);
// Restart also worker building and AI
citizen.scheduleRestart(player);
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.gui.hiring.restartMessage", citizen.getName());
}
use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.
the class HireFireMessage method onExecute.
@Override
protected void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer, final IColony colony, final IBuilding building) {
final ICitizenData citizen = colony.getCitizenManager().getCivilian(citizenID);
citizen.setPaused(false);
if (hire) {
building.getModuleMatching(IAssignsJob.class, m -> m.getJobEntry() == entry).assignCitizen(citizen);
} else {
building.getModuleMatching(IAssignsJob.class, m -> m.getJobEntry() == entry).removeCitizen(citizen);
}
}
use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.
the class AbstractBuilding method removeWorkOrder.
/**
* Remove the work order for the building.
* <p>
* Remove either the upgrade or repair work order
*/
@Override
public void removeWorkOrder() {
for (@NotNull final WorkOrderBuild o : colony.getWorkManager().getWorkOrdersOfType(WorkOrderBuild.class)) {
if (o.getSchematicLocation().equals(getID()) && (o instanceof WorkOrderBuildBuilding || o instanceof WorkOrderBuildRemoval)) {
colony.getWorkManager().removeWorkOrder(o.getID());
markDirty();
final BlockPos buildingPos = o.getClaimedBy();
final IBuilding building = colony.getBuildingManager().getBuilding(buildingPos);
if (building != null) {
for (final AbstractAssignedCitizenModule module : building.getModules(AbstractAssignedCitizenModule.class)) {
for (final ICitizenData citizen : module.getAssignedCitizen()) {
building.cancelAllRequestsOfCitizen(citizen);
}
}
}
return;
}
}
}
use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.
the class AbstractBuildingGuards method onUpgradeComplete.
// // ---- NBT Overrides ---- \\\\
/**
* We use this to set possible health multipliers and give achievements.
*
* @param newLevel The new level.
*/
@Override
public void onUpgradeComplete(final int newLevel) {
if (getAllAssignedCitizen() != null) {
for (final ICitizenData optCitizen : getAllAssignedCitizen()) {
if (optCitizen.getEntity().isPresent()) {
final AttributeModifier healthModBuildingHP = new AttributeModifier(GUARD_HEALTH_MOD_BUILDING_NAME, getBonusHealth(), AttributeModifier.Operation.ADDITION);
AttributeModifierUtils.addHealthModifier(optCitizen.getEntity().get(), healthModBuildingHP);
}
}
}
super.onUpgradeComplete(newLevel);
}
use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.
the class AbstractCraftingBuildingModule method getPendingRequestQueue.
/**
* Get a list of all recipeStorages of the pending requests in the crafters queues.
* @return the list.
*/
private List<Tuple<IRecipeStorage, Integer>> getPendingRequestQueue() {
final List<Tuple<IRecipeStorage, Integer>> recipes = new ArrayList<>();
for (final ICitizenData citizen : building.getAllAssignedCitizen()) {
if (citizen.getJob() instanceof AbstractJobCrafter) {
final List<IToken<?>> assignedTasks = new ArrayList<>(citizen.getJob(AbstractJobCrafter.class).getAssignedTasks());
assignedTasks.addAll(citizen.getJob(AbstractJobCrafter.class).getTaskQueue());
for (final IToken<?> taskToken : assignedTasks) {
final IRequest<? extends PublicCrafting> request = (IRequest<? extends PublicCrafting>) building.getColony().getRequestManager().getRequestForToken(taskToken);
final IRecipeStorage recipeStorage = IColonyManager.getInstance().getRecipeManager().getRecipes().get(request.getRequest().getRecipeID());
if (holdsRecipe(request.getRequest().getRecipeID()) && recipeStorage != null) {
recipes.add(new Tuple<>(recipeStorage, request.getRequest().getCount()));
}
}
}
}
return recipes;
}
Aggregations