use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicEnder method maintainGermlings.
@Override
protected boolean maintainGermlings(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(world, position.x, position.y, position.z)) {
continue;
}
ItemStack below = VectUtil.getAsItemStack(world, position.add(0, -1, 0));
if (!isAcceptedSoil(below)) {
continue;
}
return trySetCrop(position);
}
return false;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmHelper method getFarmSizeInDirection.
private static int getFarmSizeInDirection(World world, Vect start, ForgeDirection farmSide, ForgeDirection searchDirection) {
int size = 0;
ForgeDirection toCenter = farmSide.getOpposite();
Vect target = start.add(farmSide);
TileEntity farmTile;
do {
size++;
target = target.add(searchDirection);
Vect farmTileLocation = target.add(toCenter);
farmTile = VectUtil.getTile(world, farmTileLocation);
} while (farmTile instanceof IFarmComponent);
return size;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicPeat 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, z, direction, i);
ItemStack occupant = VectUtil.getAsItemStack(world, position);
if (occupant.getItem() == null) {
continue;
}
Block block = Block.getBlockFromItem(occupant.getItem());
if (block == null || !(block instanceof BlockSoil)) {
continue;
}
BlockSoil blockSoil = (BlockSoil) block;
BlockSoil.SoilType soilType = blockSoil.getTypeFromMeta(occupant.getItemDamage());
if (soilType == BlockSoil.SoilType.PEAT) {
crops.push(new CropPeat(world, position));
}
}
return crops;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicRubber 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.
Block block = VectUtil.getBlock(world, position);
if (!StackUtils.equals(block, PluginIC2.rubberwood)) {
return crops;
}
int meta = VectUtil.getBlockMeta(world, position);
if (meta >= 2 && meta <= 5) {
crops.push(new CropRubber(getWorld(), block, meta, position));
}
ArrayList<Vect> candidates = processHarvestBlock(crops, seen, position);
ArrayList<Vect> temp = new ArrayList<Vect>();
while (!candidates.isEmpty() && crops.size() < 100) {
for (Vect candidate : candidates) {
temp.addAll(processHarvestBlock(crops, seen, candidate));
}
candidates.clear();
candidates.addAll(temp);
temp.clear();
}
return crops;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicRubber method processHarvestBlock.
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect position) {
World world = getWorld();
ArrayList<Vect> candidates = new ArrayList<Vect>();
// Get additional candidates to return
for (int j = 0; j < 2; j++) {
Vect candidate = new Vect(position.x, position.y + j, position.z);
if (candidate.equals(position)) {
continue;
}
// See whether the given position has already been processed
if (seen.contains(candidate)) {
continue;
}
Block block = VectUtil.getBlock(world, candidate);
if (StackUtils.equals(block, PluginIC2.rubberwood)) {
int meta = VectUtil.getBlockMeta(world, candidate);
if (meta >= 2 && meta <= 5) {
crops.push(new CropRubber(world, block, meta, candidate));
}
candidates.add(candidate);
seen.add(candidate);
}
}
return candidates;
}
Aggregations