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;
}
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;
}
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;
}
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;
}
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));
}
Aggregations