use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class StructureLogic method markStructureBlocks.
protected void markStructureBlocks(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.setCentralTE((TileEntity) structure);
EnumStructureBlock type = schemata.getAt(i, j, k, isRotated);
if (metaOnValid.containsKey(type)) {
structureTile.getWorldObj().setBlockMetadataWithNotify(x, y, z, metaOnValid.get(type), Defaults.FLAG_BLOCK_SYNCH);
structureTile.getWorldObj().markBlockForUpdate(x, y, z);
}
}
}
}
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmTarget method setExtentAndYOffset.
public void setExtentAndYOffset(World world, Vect platformPosition) {
if (platformPosition == null) {
extent = 0;
return;
}
MutableVect position = new MutableVect(platformPosition);
for (extent = 0; extent < limit; extent++) {
Block platform = VectUtil.getBlock(world, position);
Vect soilPosition = new Vect(position.x, position.y + 1, position.z);
if (!StructureLogicFarm.bricks.contains(platform) || !FarmLogic.canBreakSoil(world, soilPosition)) {
break;
}
position.add(getDirection());
}
yOffset = platformPosition.getY() + 1 - getStart().getY();
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicEnder 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 FarmLogicHomogeneous method maintainSoil.
private boolean maintainSoil(int x, int yGround, int z, ForgeDirection direction, int extent) {
ItemStack[] resources = new ItemStack[] { resource };
if (!housing.hasResources(resources)) {
return false;
}
World world = getWorld();
for (int i = 0; i < extent; i++) {
Vect position = translateWithOffset(x, yGround, z, direction, i);
Block soil = VectUtil.getBlock(world, position);
if (StructureLogicFarm.bricks.contains(soil)) {
break;
}
ItemStack soilStack = VectUtil.getAsItemStack(world, position);
if (isAcceptedSoil(soilStack) || !canBreakSoil(world, position)) {
continue;
}
Vect platformPosition = position.add(0, -1, 0);
Block platformBlock = VectUtil.getBlock(world, platformPosition);
if (!StructureLogicFarm.bricks.contains(platformBlock)) {
break;
}
produce.addAll(BlockUtil.getBlockDrops(world, position));
setBlock(position, StackUtils.getBlock(soilBlock), soilBlock.getItemDamage());
housing.removeResources(resources);
return true;
}
return false;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class FarmLogicInfernal 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;
}
Aggregations