use of com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingRepairedEvent in project minecolonies by Minecolonies.
the class AbstractEntityAIStructureWithWorkOrder method executeSpecificCompleteActions.
@Override
public void executeSpecificCompleteActions() {
if (job.getBlueprint() == null && job.hasWorkOrder()) {
// fix for bad structures
job.complete();
}
if (job.getBlueprint() == null) {
return;
}
final IWorkOrder wo = job.getWorkOrder();
if (wo == null) {
Log.getLogger().error(String.format("Worker (%d:%d) ERROR - Finished, but missing work order(%d)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), job.getWorkOrderId()));
} else {
// TODO: Preferably want to use the display name of the building (in order to respect custom name) however this will require an event rework so it stores text components rather than strings
String workOrderName = wo.getWorkOrderName();
sendCompletionMessage(wo);
switch(wo.getWorkOrderType()) {
case BUILD:
job.getColony().getEventDescriptionManager().addEventDescription(new BuildingBuiltEvent(wo.getLocation(), workOrderName));
break;
case UPGRADE:
job.getColony().getEventDescriptionManager().addEventDescription(new BuildingUpgradedEvent(wo.getLocation(), workOrderName, wo.getTargetLevel()));
break;
case REPAIR:
job.getColony().getEventDescriptionManager().addEventDescription(new BuildingRepairedEvent(wo.getLocation(), workOrderName, wo.getCurrentLevel()));
break;
case REMOVE:
job.getColony().getEventDescriptionManager().addEventDescription(new BuildingDeconstructedEvent(wo.getLocation(), workOrderName, wo.getCurrentLevel()));
break;
}
job.complete();
if (wo instanceof WorkOrderBuilding) {
final IBuilding building = job.getColony().getBuildingManager().getBuilding(wo.getLocation());
switch(wo.getWorkOrderType()) {
case BUILD:
case UPGRADE:
case REPAIR:
if (building == null) {
Log.getLogger().error(String.format("Builder (%d:%d) ERROR - Finished, but missing building(%s)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), wo.getLocation()));
} else {
// Normally levels are done through the schematic data, but in case it is missing we do it manually here.
final TileEntity te = worker.level.getBlockEntity(building.getID());
if (te instanceof AbstractTileEntityColonyBuilding && ((IBlueprintDataProvider) te).getSchematicName().isEmpty()) {
building.onUpgradeComplete(wo.getTargetLevel());
building.setBuildingLevel(wo.getTargetLevel());
}
}
break;
case REMOVE:
if (building == null) {
Log.getLogger().error(String.format("Builder (%d:%d) ERROR - Finished, but missing building(%s)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), wo.getLocation()));
} else {
building.setDeconstructed();
}
break;
}
}
}
building.resetNeededResources();
}
Aggregations