Search in sources :

Example 6 with BuildingMiner

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

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)

Example 7 with BuildingMiner

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

the class EntityAIStructureMiner method checkMineShaft.

@NotNull
private IAIState checkMineShaft() {
    final BuildingMiner buildingMiner = building;
    // 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 8 with BuildingMiner

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

the class EntityAIStructureMiner method executeSpecificCompleteActions.

@Override
public void executeSpecificCompleteActions() {
    final BuildingMiner minerBuilding = building;
    // If shaft isn't cleared we're in shaft clearing mode.
    final MinerLevelManagementModule module = building.getFirstModuleOccurance(MinerLevelManagementModule.class);
    if (job.getBlueprint() != null) {
        if (job.getBlueprint().getName().contains("minermainshaft")) {
            final int depth = job.getWorkOrder().getLocation().getY();
            boolean exists = false;
            for (final Level level : module.getLevels()) {
                if (level.getDepth() == depth) {
                    exists = true;
                    break;
                }
            }
            @Nullable final BlockPos levelSignPos = WorkerUtil.findFirstLevelSign(job.getBlueprint(), job.getWorkOrder().getLocation());
            @NotNull final Level currentLevel = new Level(minerBuilding, job.getWorkOrder().getLocation().getY(), levelSignPos);
            if (!exists) {
                module.addLevel(currentLevel);
                module.setCurrentLevel(module.getNumberOfLevels());
            }
            WorkerUtil.updateLevelSign(world, currentLevel, module.getLevelId(currentLevel));
        } else {
            final Level currentLevel = module.getCurrentLevel();
            currentLevel.closeNextNode(structurePlacer.getB().getSettings().rotation.ordinal(), module.getActiveNode(), world);
            module.setActiveNode(null);
            module.setOldNode(workingNode);
            WorkerUtil.updateLevelSign(world, currentLevel, module.getLevelId(currentLevel));
        }
    }
    super.executeSpecificCompleteActions();
    // Send out update to client
    building.markDirty();
    job.setBlueprint(null);
}
Also used : MinerLevelManagementModule(com.minecolonies.coremod.colony.buildings.modules.MinerLevelManagementModule) BlockPos(net.minecraft.util.math.BlockPos) BuildingMiner(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Example 9 with BuildingMiner

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

the class EntityAIStructureMiner method executeSpecificCompleteActions.

@Override
public void executeSpecificCompleteActions() {
    final BuildingMiner minerBuilding = getOwnBuilding();
    // If shaft isn't cleared we're in shaft clearing mode.
    final MinerLevelManagementModule module = getOwnBuilding().getFirstModuleOccurance(MinerLevelManagementModule.class);
    if (job.getBlueprint() != null) {
        if (job.getBlueprint().getName().contains("minermainshaft")) {
            final int depth = job.getWorkOrder().getSchematicLocation().getY();
            boolean exists = false;
            for (final Level level : module.getLevels()) {
                if (level.getDepth() == depth) {
                    exists = true;
                    break;
                }
            }
            @Nullable final BlockPos levelSignPos = WorkerUtil.findFirstLevelSign(job.getBlueprint(), job.getWorkOrder().getSchematicLocation());
            @NotNull final Level currentLevel = new Level(minerBuilding, job.getWorkOrder().getSchematicLocation().getY(), levelSignPos);
            if (!exists) {
                module.addLevel(currentLevel);
                module.setCurrentLevel(module.getNumberOfLevels());
            }
            WorkerUtil.updateLevelSign(world, currentLevel, module.getLevelId(currentLevel));
        } else {
            final Level currentLevel = module.getCurrentLevel();
            currentLevel.closeNextNode(structurePlacer.getB().getSettings().rotation.ordinal(), module.getActiveNode(), world);
            module.setActiveNode(null);
            module.setOldNode(workingNode);
            WorkerUtil.updateLevelSign(world, currentLevel, module.getLevelId(currentLevel));
        }
    }
    super.executeSpecificCompleteActions();
    // Send out update to client
    getOwnBuilding().markDirty();
    job.setBlueprint(null);
}
Also used : MinerLevelManagementModule(com.minecolonies.coremod.colony.buildings.modules.MinerLevelManagementModule) BlockPos(net.minecraft.util.math.BlockPos) BuildingMiner(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with BuildingMiner

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

the class EntityAIStructureMiner method getNodeMiningPosition.

/**
 * Create a save mining position for the miner.
 *
 * @param blockToMine block which should be mined or placed.
 * @return the save position.
 */
private BlockPos getNodeMiningPosition(final BlockPos blockToMine) {
    final BuildingMiner buildingMiner = getOwnBuilding();
    final MinerLevelManagementModule module = buildingMiner.getFirstModuleOccurance(MinerLevelManagementModule.class);
    ;
    if (module.getCurrentLevel() == null || module.getActiveNode() == null) {
        return blockToMine;
    }
    final Vec2i parentPos = module.getActiveNode().getParent();
    final BlockPos vector = getOwnBuilding().getLadderLocation().subtract(getOwnBuilding().getCobbleLocation());
    if (parentPos != null && module.getCurrentLevel().getNode(parentPos) != null && module.getCurrentLevel().getNode(parentPos).getStyle() == Node.NodeType.SHAFT) {
        final BlockPos ladderPos = buildingMiner.getLadderLocation();
        return new BlockPos(ladderPos.getX() + vector.getX() * OTHER_SIDE_OF_SHAFT, module.getCurrentLevel().getDepth(), ladderPos.getZ() + vector.getZ() * OTHER_SIDE_OF_SHAFT);
    }
    final Vec2i pos = module.getActiveNode().getParent();
    return new BlockPos(pos.getX(), module.getCurrentLevel().getDepth(), pos.getZ());
}
Also used : MinerLevelManagementModule(com.minecolonies.coremod.colony.buildings.modules.MinerLevelManagementModule) BlockPos(net.minecraft.util.math.BlockPos) 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