Search in sources :

Example 11 with BuildingMiner

use of com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner in project minecolonies by ldtteam.

the class EntityAIStructureMiner method checkMineShaft.

@NotNull
private IAIState checkMineShaft() {
    final BuildingMiner buildingMiner = getOwnBuilding();
    // Check if we reached the bottom of the shaft
    if (getLastLadder(buildingMiner.getLadderLocation(), world) < SHAFT_BASE_DEPTH) {
        AdvancementUtils.TriggerAdvancementPlayersForColony(job.getColony(), AdvancementTriggers.DEEP_MINE::trigger);
    }
    // Check if we reached the mineshaft depth limit
    if (getLastLadder(buildingMiner.getLadderLocation(), world) < buildingMiner.getDepthLimit()) {
        // If the miner hut has been placed too deep.
        if (buildingMiner.getFirstModuleOccurance(MinerLevelManagementModule.class).getNumberOfLevels() == 0) {
            worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(NEEDS_BETTER_HUT), ChatPriority.BLOCKING));
            return IDLE;
        }
        worker.getCitizenData().setVisibleStatus(MINING);
        return MINER_MINING_NODE;
    }
    worker.getCitizenData().setVisibleStatus(MINING);
    return MINER_MINING_SHAFT;
}
Also used : StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BuildingMiner(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with BuildingMiner

use of com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner in project minecolonies by ldtteam.

the class AbstractEntityAIGuard method patrolMine.

/**
 * Patrol between all completed nodes in the assigned mine
 *
 * @return the next point to patrol to
 */
public IAIState patrolMine() {
    if (buildingGuards.getMinePos() == null) {
        return PREPARING;
    }
    if (currentPatrolPoint == null || worker.isWorkerAtSiteWithMove(currentPatrolPoint, 2)) {
        final IBuilding building = buildingGuards.getColony().getBuildingManager().getBuilding(buildingGuards.getMinePos());
        if (building != null) {
            if (building instanceof BuildingMiner) {
                final BuildingMiner buildingMiner = (BuildingMiner) building;
                final Level level = buildingMiner.getFirstModuleOccurance(MinerLevelManagementModule.class).getCurrentLevel();
                if (level == null) {
                    setNextPatrolTarget(buildingMiner.getPosition());
                } else {
                    setNextPatrolTarget(level.getRandomCompletedNode(buildingMiner));
                }
            } else {
                buildingGuards.getFirstModuleOccurance(ISettingsModule.class).getSetting(AbstractBuildingGuards.GUARD_TASK).set(GuardTaskSetting.PATROL);
            }
        } else {
            buildingGuards.getFirstModuleOccurance(ISettingsModule.class).getSetting(AbstractBuildingGuards.GUARD_TASK).set(GuardTaskSetting.PATROL);
        }
    }
    return null;
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) MinerLevelManagementModule(com.minecolonies.coremod.colony.buildings.modules.MinerLevelManagementModule) Level(com.minecolonies.coremod.entity.ai.citizen.miner.Level) BuildingMiner(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner)

Aggregations

BuildingMiner (com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner)12 MinerLevelManagementModule (com.minecolonies.coremod.colony.buildings.modules.MinerLevelManagementModule)8 BlockPos (net.minecraft.util.math.BlockPos)8 NotNull (org.jetbrains.annotations.NotNull)6 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 StandardInteraction (com.minecolonies.coremod.colony.interactionhandling.StandardInteraction)2 Level (com.minecolonies.coremod.entity.ai.citizen.miner.Level)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 Nullable (org.jetbrains.annotations.Nullable)2