Search in sources :

Example 6 with BuildingMiner

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

the class EntityAIStructureMiner method lookForLadder.

@NotNull
private AIState lookForLadder() {
    @Nullable final BuildingMiner buildingMiner = getOwnBuilding();
    //Check for already found ladder
    if (buildingMiner.hasFoundLadder() && buildingMiner.getLadderLocation() != null) {
        if (world.getBlockState(buildingMiner.getLadderLocation()).getBlock() == Blocks.LADDER) {
            return MINER_WALKING_TO_LADDER;
        } else {
            buildingMiner.setFoundLadder(false);
            buildingMiner.setLadderLocation(null);
        }
    }
    final int posX = buildingMiner.getLocation().getX();
    final int posY = buildingMiner.getLocation().getY() + 2;
    final int posZ = buildingMiner.getLocation().getZ();
    for (int y = posY - LADDER_SEARCH_RANGE; y < posY; y++) {
        for (int x = posX - LADDER_SEARCH_RANGE; x < posX + LADDER_SEARCH_RANGE; x++) {
            for (int z = posZ - LADDER_SEARCH_RANGE; z < posZ + LADDER_SEARCH_RANGE; z++) {
                tryFindLadderAt(new BlockPos(x, y, z));
            }
        }
    }
    return MINER_SEARCHING_LADDER;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) BuildingMiner(com.minecolonies.coremod.colony.buildings.BuildingMiner) Nullable(org.jetbrains.annotations.Nullable) NotNull(org.jetbrains.annotations.NotNull)

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