Search in sources :

Example 1 with MutableVect

use of forestry.core.vect.MutableVect in project ForestryMC by ForestryMC.

the class FarmTarget method setExtentAndYOffset.

public void setExtentAndYOffset(World world, Vect platformPosition) {
    if (platformPosition == null) {
        extent = 0;
        return;
    }
    MutableVect position = new MutableVect(platformPosition);
    for (extent = 0; extent < limit; extent++) {
        Block platform = VectUtil.getBlock(world, position);
        Vect soilPosition = new Vect(position.x, position.y + 1, position.z);
        if (!StructureLogicFarm.bricks.contains(platform) || !FarmLogic.canBreakSoil(world, soilPosition)) {
            break;
        }
        position.add(getDirection());
    }
    yOffset = platformPosition.getY() + 1 - getStart().getY();
}
Also used : MutableVect(forestry.core.vect.MutableVect) Vect(forestry.core.vect.Vect) MutableVect(forestry.core.vect.MutableVect) Block(net.minecraft.block.Block)

Example 2 with MutableVect

use of forestry.core.vect.MutableVect in project ForestryMC by ForestryMC.

the class FarmHelper method getFarmMultiblockEdge.

private static Vect getFarmMultiblockEdge(World world, Vect start, ForgeDirection direction) {
    MutableVect edge = new MutableVect(start);
    while (VectUtil.getTile(world, edge) instanceof IFarmComponent) {
        edge.add(direction);
    }
    edge.add(direction.getOpposite());
    return new Vect(edge);
}
Also used : IFarmComponent(forestry.api.farming.IFarmComponent) MutableVect(forestry.core.vect.MutableVect) Vect(forestry.core.vect.Vect) MutableVect(forestry.core.vect.MutableVect)

Example 3 with MutableVect

use of forestry.core.vect.MutableVect in project ForestryMC by ForestryMC.

the class FarmLogicCocoa method tryPlantingCocoa.

private boolean tryPlantingCocoa(Vect position) {
    World world = getWorld();
    MutableVect current = new MutableVect(position);
    while (VectUtil.isWoodBlock(world, current) && BlockLog.func_150165_c(VectUtil.getBlockMeta(world, current)) == 3) {
        for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
            if (direction == ForgeDirection.UP || direction == ForgeDirection.DOWN) {
                continue;
            }
            Vect candidate = new Vect(current.x + direction.offsetX, current.y, current.z + direction.offsetZ);
            if (VectUtil.isAirBlock(world, candidate)) {
                return housing.plantGermling(cocoa, world, candidate.x, candidate.y, candidate.z);
            }
        }
        current.y++;
        if (current.y - position.y > 1) {
            break;
        }
    }
    return false;
}
Also used : MutableVect(forestry.core.vect.MutableVect) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Vect(forestry.core.vect.Vect) MutableVect(forestry.core.vect.MutableVect) World(net.minecraft.world.World)

Example 4 with MutableVect

use of forestry.core.vect.MutableVect in project ForestryMC by ForestryMC.

the class Bee method hasFlower.

@Override
public boolean hasFlower(IBeeHousing housing) {
    IFlowerProvider provider = genome.getFlowerProvider();
    Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
    Vect area = getArea(genome, housing);
    Vect offset = new Vect(-area.x / 2, -area.y / 2, -area.z / 2);
    boolean hasFlower = false;
    MutableVect posCurrent = new MutableVect(0, 0, 0);
    while (posCurrent.advancePositionInArea(area)) {
        Vect posBlock = Vect.add(housingPos, posCurrent, offset);
        if (provider.isAcceptedFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z)) {
            hasFlower = true;
            break;
        }
    }
    return hasFlower;
}
Also used : IFlowerProvider(forestry.api.genetics.IFlowerProvider) MutableVect(forestry.core.vect.MutableVect) Vect(forestry.core.vect.Vect) MutableVect(forestry.core.vect.MutableVect)

Aggregations

MutableVect (forestry.core.vect.MutableVect)4 Vect (forestry.core.vect.Vect)4 IFarmComponent (forestry.api.farming.IFarmComponent)1 IFlowerProvider (forestry.api.genetics.IFlowerProvider)1 Block (net.minecraft.block.Block)1 World (net.minecraft.world.World)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1