Search in sources :

Example 11 with Vect

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

the class FarmLogicInfernal method harvest.

@Override
public Collection<ICrop> harvest(int x, int y, int z, ForgeDirection direction, int extent) {
    World world = getWorld();
    Stack<ICrop> crops = new Stack<ICrop>();
    for (int i = 0; i < extent; i++) {
        Vect position = translateWithOffset(x, y + 1, z, direction, i);
        for (IFarmable farmable : germlings) {
            ICrop crop = farmable.getCropAt(world, position.x, position.y, position.z);
            if (crop != null) {
                crops.push(crop);
            }
        }
    }
    return crops;
}
Also used : IFarmable(forestry.api.farming.IFarmable) Vect(forestry.core.vect.Vect) World(net.minecraft.world.World) ICrop(forestry.api.farming.ICrop) Stack(java.util.Stack) ItemStack(net.minecraft.item.ItemStack)

Example 12 with Vect

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

the class FarmLogicRubber method harvest.

@Override
public Collection<ICrop> harvest(int x, int y, int z, ForgeDirection direction, int extent) {
    if (inActive) {
        return null;
    }
    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 13 with Vect

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

the class FarmLogicSucculent method harvest.

@Override
public Collection<ICrop> harvest(int x, int y, int z, ForgeDirection direction, int extent) {
    World world = getWorld();
    Stack<ICrop> crops = new Stack<ICrop>();
    for (int i = 0; i < extent; i++) {
        Vect position = translateWithOffset(x, y + 1, z, direction, i);
        for (IFarmable seed : germlings) {
            ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
            if (crop != null) {
                crops.push(crop);
            }
        }
    }
    return crops;
}
Also used : IFarmable(forestry.api.farming.IFarmable) Vect(forestry.core.vect.Vect) World(net.minecraft.world.World) ICrop(forestry.api.farming.ICrop) Stack(java.util.Stack) ItemStack(net.minecraft.item.ItemStack)

Example 14 with Vect

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

the class FarmLogicWatered method maintainSoil.

private boolean maintainSoil(int x, int y, int z, ForgeDirection direction, int extent) {
    World world = getWorld();
    ItemStack[] resources = new ItemStack[] { resource };
    for (int i = 0; i < extent; i++) {
        Vect position = translateWithOffset(x, y, z, direction, i);
        Block block = VectUtil.getBlock(world, position);
        if (!isAirBlock(block) && !Utils.isReplaceableBlock(block)) {
            ItemStack blockStack = VectUtil.getAsItemStack(world, position);
            if (!isAcceptedGround(blockStack) && housing.hasResources(resources)) {
                produce.addAll(BlockUtil.getBlockDrops(getWorld(), position));
                setBlock(position, Blocks.air, 0);
                return trySetSoil(position);
            }
            continue;
        }
        if (isManual || isWaterSourceBlock(world, position)) {
            continue;
        }
        if (trySetWater(world, position)) {
            return true;
        }
        return trySetSoil(position);
    }
    return false;
}
Also used : Vect(forestry.core.vect.Vect) Block(net.minecraft.block.Block) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 15 with Vect

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

the class FarmableCocoa method getCropAt.

@Override
public ICrop getCropAt(World world, int x, int y, int z) {
    Block block = world.getBlock(x, y, z);
    if (block != COCOA_PLANT) {
        return null;
    }
    int meta = world.getBlockMetadata(x, y, z);
    if (BlockUtil.getMaturityPod(meta) < 2) {
        return null;
    }
    return new CropBlock(world, block, meta, new Vect(x, y, z));
}
Also used : Vect(forestry.core.vect.Vect) Block(net.minecraft.block.Block)

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