Search in sources :

Example 16 with Vect

use of forestry.core.vect.Vect 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);
}
Also used : IFarmComponent(forestry.api.farming.IFarmComponent) MutableVect(forestry.core.vect.MutableVect) Vect(forestry.core.vect.Vect) MutableVect(forestry.core.vect.MutableVect)

Example 17 with Vect

use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.

the class FarmHelper method getFarmSizeNorthSouth.

public static int getFarmSizeNorthSouth(World world, Vect start) {
    ForgeDirection farmSide = ForgeDirection.NORTH;
    ForgeDirection startSide = ForgeDirection.EAST;
    Vect corner = getFarmMultiblockCorner(world, start, farmSide, startSide);
    return getFarmSizeInDirection(world, corner, farmSide, startSide.getOpposite());
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Vect(forestry.core.vect.Vect) MutableVect(forestry.core.vect.MutableVect)

Example 18 with Vect

use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.

the class FarmHelper method getFarmSizeEastWest.

public static int getFarmSizeEastWest(World world, Vect start) {
    ForgeDirection farmSide = ForgeDirection.EAST;
    ForgeDirection startSide = ForgeDirection.NORTH;
    Vect corner = getFarmMultiblockCorner(world, start, farmSide, startSide);
    return getFarmSizeInDirection(world, corner, farmSide, startSide.getOpposite());
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Vect(forestry.core.vect.Vect) MutableVect(forestry.core.vect.MutableVect)

Example 19 with Vect

use of forestry.core.vect.Vect 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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IFarmComponent(forestry.api.farming.IFarmComponent) ITileStructure(forestry.api.core.ITileStructure) Vect(forestry.core.vect.Vect) Block(net.minecraft.block.Block) EnumStructureBlock(forestry.core.utils.Schemata.EnumStructureBlock) EnumStructureBlock(forestry.core.utils.Schemata.EnumStructureBlock)

Example 20 with Vect

use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.

the class FarmLogicArboreal method maintainGermlings.

@Override
protected boolean maintainGermlings(int x, int ySaplings, int z, ForgeDirection direction, int extent) {
    World world = getWorld();
    for (int i = 0; i < extent; i++) {
        Vect position = translateWithOffset(x, ySaplings, z, direction, i);
        if (VectUtil.isAirBlock(world, position)) {
            Vect soilBelowPosition = new Vect(position.x, position.y - 1, position.z);
            ItemStack soilBelow = VectUtil.getAsItemStack(world, soilBelowPosition);
            if (isAcceptedSoil(soilBelow)) {
                return plantSapling(position);
            }
        }
    }
    return false;
}
Also used : Vect(forestry.core.vect.Vect) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Vect (forestry.core.vect.Vect)59 World (net.minecraft.world.World)28 ItemStack (net.minecraft.item.ItemStack)19 ICrop (forestry.api.farming.ICrop)18 MutableVect (forestry.core.vect.MutableVect)15 Block (net.minecraft.block.Block)15 Stack (java.util.Stack)11 ArrayList (java.util.ArrayList)10 TileEntity (net.minecraft.tileentity.TileEntity)9 IFarmable (forestry.api.farming.IFarmable)7 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)7 ITileStructure (forestry.api.core.ITileStructure)4 HashSet (java.util.HashSet)4 Random (java.util.Random)4 IFarmComponent (forestry.api.farming.IFarmComponent)3 EnumStructureBlock (forestry.core.utils.Schemata.EnumStructureBlock)3 IVect (forestry.core.vect.IVect)3 List (java.util.List)3 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)3 EnumTemperature (forestry.api.core.EnumTemperature)2