Search in sources :

Example 56 with Vect

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

the class FarmLogicOrchard method getHarvestBlocks.

private Collection<ICrop> getHarvestBlocks(Vect position) {
    Set<Vect> seen = new HashSet<Vect>();
    Stack<ICrop> crops = new Stack<ICrop>();
    World world = getWorld();
    // Determine what type we want to harvest.
    if (!VectUtil.isWoodBlock(world, position) && !isFruitBearer(world, position)) {
        return crops;
    }
    List<Vect> candidates = processHarvestBlock(crops, seen, position, position);
    List<Vect> temp = new ArrayList<Vect>();
    while (!candidates.isEmpty() && crops.size() < 20) {
        for (Vect candidate : candidates) {
            temp.addAll(processHarvestBlock(crops, seen, position, candidate));
        }
        candidates.clear();
        candidates.addAll(temp);
        temp.clear();
    }
    return crops;
}
Also used : Vect(forestry.core.vect.Vect) ArrayList(java.util.ArrayList) World(net.minecraft.world.World) ICrop(forestry.api.farming.ICrop) HashSet(java.util.HashSet) Stack(java.util.Stack) ItemStack(net.minecraft.item.ItemStack)

Example 57 with Vect

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

the class FarmLogicOrchard method harvest.

@Override
public Collection<ICrop> harvest(int x, int y, int z, ForgeDirection direction, int extent) {
    Vect start = new Vect(x, y, z);
    if (!lastExtents.containsKey(start)) {
        lastExtents.put(start, 0);
    }
    int lastExtent = lastExtents.get(start);
    if (lastExtent > extent) {
        lastExtent = 0;
    }
    Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
    Collection<ICrop> crops = getHarvestBlocks(position);
    lastExtent++;
    lastExtents.put(start, lastExtent);
    return crops;
}
Also used : Vect(forestry.core.vect.Vect) ICrop(forestry.api.farming.ICrop)

Example 58 with Vect

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

the class FarmLogicCrops method maintainCrops.

@Override
protected boolean maintainCrops(int x, int y, int z, ForgeDirection direction, int extent) {
    World world = getWorld();
    for (int i = 0; i < extent; i++) {
        Vect position = translateWithOffset(x, y, z, direction, i);
        if (!VectUtil.isAirBlock(world, position) && !Utils.isReplaceableBlock(getWorld(), position.x, position.y, position.z)) {
            continue;
        }
        ItemStack below = VectUtil.getAsItemStack(world, position.add(0, -1, 0));
        if (ground.getItem() != below.getItem()) {
            continue;
        }
        if (below.getItemDamage() <= 0) {
            continue;
        }
        return trySetCrop(position);
    }
    return false;
}
Also used : Vect(forestry.core.vect.Vect) IVect(forestry.core.vect.IVect) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 59 with Vect

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

the class AlleleLeafEffectNone method getBounding.

protected AxisAlignedBB getBounding(int x, int y, int z, float modifier) {
    int[] areaAr = DEFAULT_EFFECT_AREA;
    Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(modifier);
    Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
    Vect min = new Vect(x + offset.x, y + offset.y, y + offset.z);
    Vect max = new Vect(x + offset.x + area.x, y + offset.y + area.y, y + offset.z + area.z);
    return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
}
Also used : Vect(forestry.core.vect.Vect)

Aggregations

Vect (forestry.core.vect.Vect)59 World (net.minecraft.world.World)28 ItemStack (net.minecraft.item.ItemStack)19 ICrop (forestry.api.farming.ICrop)18 MutableVect (forestry.core.vect.MutableVect)15 Block (net.minecraft.block.Block)15 Stack (java.util.Stack)11 ArrayList (java.util.ArrayList)10 TileEntity (net.minecraft.tileentity.TileEntity)9 IFarmable (forestry.api.farming.IFarmable)7 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)7 ITileStructure (forestry.api.core.ITileStructure)4 HashSet (java.util.HashSet)4 Random (java.util.Random)4 IFarmComponent (forestry.api.farming.IFarmComponent)3 EnumStructureBlock (forestry.core.utils.Schemata.EnumStructureBlock)3 IVect (forestry.core.vect.IVect)3 List (java.util.List)3 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)3 EnumTemperature (forestry.api.core.EnumTemperature)2