Search in sources :

Example 6 with WorkOrderBuild

use of com.minecolonies.coremod.colony.workorders.WorkOrderBuild in project minecolonies by Minecolonies.

the class EntityAIStructureBuilder method executeSpecificCompleteActions.

@Override
public void executeSpecificCompleteActions() {
    if (job.getStructure() == null && job.hasWorkOrder()) {
        //fix for bad structures
        job.complete();
    }
    if (job.getStructure() == null) {
        return;
    }
    final String structureName = job.getStructure().getName();
    worker.sendLocalizedChat(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_BUILDCOMPLETE, structureName);
    final WorkOrderBuildDecoration wo = job.getWorkOrder();
    if (wo == null) {
        Log.getLogger().error(String.format("Builder (%d:%d) ERROR - Finished, but missing work order(%d)", worker.getColony().getID(), worker.getCitizenData().getId(), job.getWorkOrderId()));
    } else {
        final WorkOrderBuild woh = (wo instanceof WorkOrderBuild) ? (WorkOrderBuild) wo : null;
        if (woh == null && structureName.contains(WAYPOINT_STRING)) {
            worker.getColony().addWayPoint(wo.getBuildingLocation(), world.getBlockState(wo.getBuildingLocation()));
        } else if (woh != null) {
            final AbstractBuilding building = job.getColony().getBuilding(wo.getBuildingLocation());
            if (building == null) {
                Log.getLogger().error(String.format("Builder (%d:%d) ERROR - Finished, but missing building(%s)", worker.getColony().getID(), worker.getCitizenData().getId(), woh.getBuildingLocation()));
            } else {
                building.setBuildingLevel(woh.getUpgradeLevel());
            }
        }
        job.complete();
    }
    final BuildingBuilder workerBuilding = (BuildingBuilder) getOwnBuilding();
    workerBuilding.resetNeededResources();
    resetTask();
}
Also used : WorkOrderBuild(com.minecolonies.coremod.colony.workorders.WorkOrderBuild) BuildingBuilder(com.minecolonies.coremod.colony.buildings.BuildingBuilder) WorkOrderBuildDecoration(com.minecolonies.coremod.colony.workorders.WorkOrderBuildDecoration) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding)

Aggregations

WorkOrderBuild (com.minecolonies.coremod.colony.workorders.WorkOrderBuild)6 WorkOrderBuildDecoration (com.minecolonies.coremod.colony.workorders.WorkOrderBuildDecoration)4 AbstractBuilding (com.minecolonies.coremod.colony.buildings.AbstractBuilding)2 NotNull (org.jetbrains.annotations.NotNull)2 BuildingBuilder (com.minecolonies.coremod.colony.buildings.BuildingBuilder)1 BlockPos (net.minecraft.util.math.BlockPos)1