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;
}
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;
}
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);
}
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);
}
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());
}
Aggregations