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