use of forestry.api.farming.IFarmComponent in project ForestryMC by ForestryMC.
the class FarmHelper method getFarmMultiblockEdge.
private static Vect getFarmMultiblockEdge(World world, Vect start, ForgeDirection direction) {
MutableVect edge = new MutableVect(start);
while (VectUtil.getTile(world, edge) instanceof IFarmComponent) {
edge.add(direction);
}
edge.add(direction.getOpposite());
return new Vect(edge);
}
use of forestry.api.farming.IFarmComponent in project ForestryMC by ForestryMC.
the class StructureLogicFarm method determineMasterState.
@Override
protected EnumStructureState determineMasterState(Schemata schemata, boolean rotate) {
Vect dimensions = schemata.getDimensions(rotate);
int offsetX = schemata.getxOffset();
int offsetZ = schemata.getzOffset();
if (rotate) {
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;
if (!structureTile.getWorldObj().blockExists(x, y, z)) {
return EnumStructureState.INDETERMINATE;
}
EnumStructureBlock required = schemata.getAt(i, j, k, rotate);
if (required == EnumStructureBlock.ANY) {
continue;
}
TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z);
Block block = structureTile.getWorldObj().getBlock(x, y, z);
switch(required) {
case AIR:
if (!block.isAir(structureTile.getWorldObj(), x, y, z)) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_A:
if (tile == null || !(tile instanceof IFarmComponent)) {
return EnumStructureState.INVALID;
}
if (!((ITileStructure) tile).getTypeUID().equals(UID_FARM)) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_B:
case MASTER:
if (tile == null || !(tile instanceof TileFarm)) {
return EnumStructureState.INVALID;
}
if (((TileFarm) tile).hasFunction()) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_C:
if (!bricks.contains(block)) {
return EnumStructureState.INVALID;
}
break;
case FOREIGN:
if (tile instanceof ITileStructure) {
return EnumStructureState.INVALID;
}
break;
default:
return EnumStructureState.INDETERMINATE;
}
}
}
}
return EnumStructureState.VALID;
}
use of forestry.api.farming.IFarmComponent in project ForestryMC by ForestryMC.
the class TileControl method registerWithMaster.
private void registerWithMaster() {
if (!hasMaster()) {
return;
}
ITileStructure central = getCentralTE();
if (!(central instanceof IFarmComponent)) {
return;
}
((IFarmComponent) central).registerListener(this);
}
use of forestry.api.farming.IFarmComponent 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;
}
Aggregations