Search in sources :

Example 1 with BuildingMiner

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());
}
Also used : Vec2i(com.minecolonies.api.util.Vec2i) BlockPos(net.minecraft.util.math.BlockPos) BuildingMiner(com.minecolonies.coremod.colony.buildings.BuildingMiner)

Example 2 with BuildingMiner

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();
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) BuildingMiner(com.minecolonies.coremod.colony.buildings.BuildingMiner) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with BuildingMiner

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;
}
Also used : AbstractBuildingWorker(com.minecolonies.coremod.colony.buildings.AbstractBuildingWorker) JobMiner(com.minecolonies.coremod.colony.jobs.JobMiner) BlockPos(net.minecraft.util.math.BlockPos) BuildingMiner(com.minecolonies.coremod.colony.buildings.BuildingMiner) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with BuildingMiner

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);
}
Also used : BuildingMiner(com.minecolonies.coremod.colony.buildings.BuildingMiner) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with BuildingMiner

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);
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) BuildingMiner(com.minecolonies.coremod.colony.buildings.BuildingMiner) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

BuildingMiner (com.minecolonies.coremod.colony.buildings.BuildingMiner)6 BlockPos (net.minecraft.util.math.BlockPos)5 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 Vec2i (com.minecolonies.api.util.Vec2i)1 AbstractBuildingWorker (com.minecolonies.coremod.colony.buildings.AbstractBuildingWorker)1 JobMiner (com.minecolonies.coremod.colony.jobs.JobMiner)1 EnumFacing (net.minecraft.util.EnumFacing)1