Search in sources :

Example 6 with Vect

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

Example 7 with Vect

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();
}
Also used : MutableVect(forestry.core.vect.MutableVect) Vect(forestry.core.vect.Vect) MutableVect(forestry.core.vect.MutableVect) Block(net.minecraft.block.Block)

Example 8 with Vect

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;
}
Also used : IFarmable(forestry.api.farming.IFarmable) Vect(forestry.core.vect.Vect) World(net.minecraft.world.World) ICrop(forestry.api.farming.ICrop) Stack(java.util.Stack) ItemStack(net.minecraft.item.ItemStack)

Example 9 with Vect

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;
}
Also used : Vect(forestry.core.vect.Vect) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World)

Example 10 with Vect

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;
}
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