use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicArboreal method processHarvestBlock.
private ArrayList<Vect> processHarvestBlock(IFarmable germling, Stack<ICrop> crops, Set<Vect> seen, Vect start, Vect position) {
World world = getWorld();
ArrayList<Vect> candidates = new ArrayList<Vect>();
// Get additional candidates to return
for (int i = -1; i < 2; i++) {
for (int j = yOffset; j < 2; j++) {
for (int k = -1; k < 2; k++) {
Vect candidate = new Vect(position.x + i, position.y + j, position.z + k);
if (candidate.equals(position)) {
continue;
}
if (Math.abs(candidate.x - start.x) > 5) {
continue;
}
if (Math.abs(candidate.z - start.z) > 5) {
continue;
}
// See whether the given position has already been processed
if (seen.contains(candidate)) {
continue;
}
ICrop crop = germling.getCropAt(world, candidate.x, candidate.y, candidate.z);
if (crop != null) {
crops.push(crop);
candidates.add(candidate);
seen.add(candidate);
}
}
}
}
return candidates;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicArboreal 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 (!lastExtentsHarvest.containsKey(start)) {
lastExtentsHarvest.put(start, 0);
}
int lastExtent = lastExtentsHarvest.get(start);
if (lastExtent > extent) {
lastExtent = 0;
}
Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
Collection<ICrop> crops = getHarvestBlocks(position);
lastExtent++;
lastExtentsHarvest.put(start, lastExtent);
return crops;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicCocoa method processHarvestBlock.
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect start, Vect position) {
World world = getWorld();
ArrayList<Vect> candidates = new ArrayList<Vect>();
// Get additional candidates to return
for (int i = -1; i < 2; i++) {
for (int j = 0; j < 2; j++) {
for (int k = -1; k < 2; k++) {
Vect candidate = new Vect(position.x + i, position.y + j, position.z + k);
if (candidate.equals(position)) {
continue;
}
if (Math.abs(candidate.x - start.x) > 5) {
continue;
}
if (Math.abs(candidate.z - start.z) > 5) {
continue;
}
// See whether the given position has already been processed
if (seen.contains(candidate)) {
continue;
}
ICrop crop = cocoa.getCropAt(world, candidate.x, candidate.y, candidate.z);
if (crop != null) {
crops.push(crop);
candidates.add(candidate);
seen.add(candidate);
} else if (VectUtil.isWoodBlock(world, candidate)) {
candidates.add(candidate);
seen.add(candidate);
}
}
}
}
return candidates;
}
use of forestry.core.vect.Vect 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;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicCocoa 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 (!lastExtentsHarvest.containsKey(start)) {
lastExtentsHarvest.put(start, 0);
}
int lastExtent = lastExtentsHarvest.get(start);
if (lastExtent > extent) {
lastExtent = 0;
}
Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
Collection<ICrop> crops = getHarvestBlocks(position);
lastExtent++;
lastExtentsHarvest.put(start, lastExtent);
return crops;
}
Aggregations