use of com.minecolonies.coremod.colony.buildings.BuildingMiner in project minecolonies by Minecolonies.
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();
if (buildingMiner.getCurrentLevel() == null || buildingMiner.getCurrentLevel().getRandomNode() == null) {
return blockToMine;
}
final Vec2i parentPos = buildingMiner.getCurrentLevel().getRandomNode().getParent();
if (parentPos != null && buildingMiner.getCurrentLevel().getNode(parentPos) != null && buildingMiner.getCurrentLevel().getNode(parentPos).getStyle() == Node.NodeType.SHAFT) {
final BlockPos ladderPos = buildingMiner.getLadderLocation();
return new BlockPos(ladderPos.getX() + buildingMiner.getVectorX() * OTHER_SIDE_OF_SHAFT, buildingMiner.getCurrentLevel().getDepth(), ladderPos.getZ() + buildingMiner.getVectorZ() * OTHER_SIDE_OF_SHAFT);
}
final Vec2i pos = buildingMiner.getCurrentLevel().getRandomNode().getParent();
return new BlockPos(pos.getX(), buildingMiner.getCurrentLevel().getDepth(), pos.getZ());
}
use of com.minecolonies.coremod.colony.buildings.BuildingMiner in project minecolonies by Minecolonies.
the class EntityAIStructureMiner method tryFindLadderAt.
private void tryFindLadderAt(@NotNull final BlockPos pos) {
@Nullable final BuildingMiner buildingMiner = getOwnBuilding();
if (buildingMiner.hasFoundLadder()) {
return;
}
if (world.getBlockState(pos).getBlock().equals(Blocks.LADDER)) {
final int firstLadderY = getFirstLadder(pos);
buildingMiner.setLadderLocation(new BlockPos(pos.getX(), firstLadderY, pos.getZ()));
validateLadderOrientation();
}
}
use of com.minecolonies.coremod.colony.buildings.BuildingMiner in project minecolonies by Minecolonies.
the class WalkToProxy method fillProxyList.
/**
* Calculates a list of proxies to a certain target for a worker.
*
* @param target the target.
* @param distanceToPath the complete distance.
* @return the first position to path to.
*/
@NotNull
private BlockPos fillProxyList(@NotNull final BlockPos target, final double distanceToPath) {
final BlockPos proxyPoint;
final AbstractBuildingWorker building = worker.getWorkBuilding();
if (worker.getColonyJob() != null && worker.getColonyJob() instanceof JobMiner && building instanceof BuildingMiner) {
proxyPoint = getMinerProxy(target, distanceToPath, (BuildingMiner) building);
} else {
proxyPoint = getProxy(target, worker.getPosition(), distanceToPath);
}
if (!proxyList.isEmpty()) {
proxyList.remove(0);
}
return proxyPoint;
}
use of com.minecolonies.coremod.colony.buildings.BuildingMiner in project minecolonies by Minecolonies.
the class EntityAIStructureMiner method executeSpecificCompleteActions.
@Override
public void executeSpecificCompleteActions() {
final BuildingMiner minerBuilding = getOwnBuilding();
//If shaft isn't cleared we're in shaft clearing mode.
if (minerBuilding.clearedShaft) {
minerBuilding.getCurrentLevel().closeNextNode(getRotation());
} else {
@NotNull final Level currentLevel = new Level(minerBuilding, job.getStructure().getPosition().getY());
minerBuilding.addLevel(currentLevel);
minerBuilding.setCurrentLevel(minerBuilding.getNumberOfLevels());
minerBuilding.resetStartingLevelShaft();
}
//Send out update to client
getOwnBuilding().markDirty();
job.setStructure(null);
}
use of com.minecolonies.coremod.colony.buildings.BuildingMiner in project minecolonies by Minecolonies.
the class EntityAIStructureMiner method validateLadderOrientation.
private void validateLadderOrientation() {
@Nullable final BuildingMiner buildingMiner = getOwnBuilding();
final EnumFacing ladderOrientation = world.getBlockState(buildingMiner.getLadderLocation()).getValue(BlockLadder.FACING);
if (ladderOrientation == EnumFacing.WEST) {
buildingMiner.setVectorX(-1);
buildingMiner.setVectorZ(0);
} else if (ladderOrientation == EnumFacing.EAST) {
buildingMiner.setVectorX(1);
buildingMiner.setVectorZ(0);
} else if (ladderOrientation == EnumFacing.SOUTH) {
buildingMiner.setVectorX(0);
buildingMiner.setVectorZ(1);
} else if (ladderOrientation == EnumFacing.NORTH) {
buildingMiner.setVectorX(0);
buildingMiner.setVectorZ(-1);
} else {
throw new IllegalStateException("Ladder metadata was " + ladderOrientation);
}
final int x = buildingMiner.getLadderLocation().getX();
final int y = buildingMiner.getLadderLocation().getY();
final int z = buildingMiner.getLadderLocation().getZ();
buildingMiner.setCobbleLocation(new BlockPos(x - buildingMiner.getVectorX(), y, z - buildingMiner.getVectorZ()));
buildingMiner.setShaftStart(new BlockPos(x, getLastLadder(buildingMiner.getLadderLocation()) - 1, z));
buildingMiner.setFoundLadder(true);
}
Aggregations