use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicCrops 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 : seeds) {
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 FarmLogicCrops method collect.
@SuppressWarnings("unchecked")
@Override
public Collection<ItemStack> collect() {
Collection<ItemStack> products = produce;
produce = new ArrayList<ItemStack>();
Vect coords = new Vect(housing.getCoords());
Vect area = new Vect(housing.getArea());
Vect offset = new Vect(housing.getOffset());
Vect min = coords.add(offset);
Vect max = min.add(area);
AxisAlignedBB harvestBox = AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
List<Entity> list = housing.getWorld().getEntitiesWithinAABB(Entity.class, harvestBox);
int i;
for (i = 0; i < list.size(); i++) {
Entity entity = list.get(i);
if (entity instanceof EntityItem) {
EntityItem item = (EntityItem) entity;
if (!item.isDead) {
ItemStack contained = item.getEntityItem();
if (isAcceptedGermling(contained) || isWindfall(contained)) {
produce.add(contained.copy());
item.setDead();
}
}
}
}
return products;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicOrchard method processHarvestBlock.
private List<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect start, Vect position) {
World world = getWorld();
List<Vect> candidates = new ArrayList<Vect>();
// Get additional candidates to return
for (int i = -2; i < 3; 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 (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;
}
if (VectUtil.isWoodBlock(world, candidate)) {
candidates.add(candidate);
seen.add(candidate);
} else if (isFruitBearer(world, candidate)) {
candidates.add(candidate);
seen.add(candidate);
ICrop crop = getCrop(world, candidate);
if (crop != null) {
crops.push(crop);
}
}
}
}
}
return candidates;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmableFarmCraftory method getCropAt.
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (block != PluginFarmCraftory.blockSingle && block != PluginFarmCraftory.blockMulti) {
return null;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (tile == null) {
return null;
}
if (PluginFarmCraftory.getGrowthStage(tile) < 2) {
return null;
}
return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z));
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class StructureLogic method resetStructureBlocks.
protected void resetStructureBlocks(Schemata schemata) {
Vect dimensions = schemata.getDimensions(isRotated);
int offsetX = schemata.getxOffset();
int offsetZ = schemata.getzOffset();
if (isRotated) {
offsetX = schemata.getzOffset();
offsetZ = schemata.getxOffset();
}
for (int i = 0; i < dimensions.x; i++) {
for (int j = 0; j < schemata.getHeight(); j++) {
for (int k = 0; k < dimensions.z; k++) {
int x = structureTile.xCoord + i + offsetX;
int y = structureTile.yCoord + j + schemata.getyOffset();
int z = structureTile.zCoord + k + offsetZ;
TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z);
if (!(tile instanceof ITileStructure)) {
continue;
}
ITileStructure part = (ITileStructure) tile;
if (!part.getTypeUID().equals(getTypeUID())) {
continue;
}
part.onStructureReset();
}
}
}
}
Aggregations