Search in sources :

Example 6 with BlockPosition

use of powercrystals.core.position.BlockPosition in project MineFactoryReloaded by powercrystals.

the class RedstoneNetwork method mergeNetwork.

public void mergeNetwork(RedstoneNetwork network) {
    if (_invalid) {
        return;
    }
    RedstoneNetwork.log("Network with ID %d merging with network %d", _id, network._id);
    network.setInvalid();
    for (int subnet = 0; subnet < 16; subnet++) {
        _singleNodes.get(subnet).addAll(network._singleNodes.get(subnet));
    }
    _omniNodes.addAll(network._omniNodes);
    _weakNodes.addAll(network._weakNodes);
    _mustUpdate = _mustUpdate || network._mustUpdate;
    for (BlockPosition cable : network._cables) {
        _cables.add(cable);
        TileEntity te = cable.getTileEntity(_world);
        if (te instanceof TileEntityRedNetCable) {
            ((TileEntityRedNetCable) te).setNetwork(this);
        }
    }
    updatePowerLevels();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockPosition(powercrystals.core.position.BlockPosition)

Example 7 with BlockPosition

use of powercrystals.core.position.BlockPosition in project MineFactoryReloaded by powercrystals.

the class TileEntityFertilizer method activateMachine.

@Override
public boolean activateMachine() {
    BlockPosition bp = _areaManager.getNextBlock();
    int targetId = worldObj.getBlockId(bp.x, bp.y, bp.z);
    if (!MFRRegistry.getFertilizables().containsKey(new Integer(targetId))) {
        setIdleTicks(getIdleTicksMax());
        return false;
    }
    for (int stackIndex = 0; stackIndex < getSizeInventory(); stackIndex++) {
        ItemStack fertStack = getStackInSlot(stackIndex);
        if (fertStack == null || !MFRRegistry.getFertilizers().containsKey(new Integer(fertStack.itemID))) {
            continue;
        }
        IFactoryFertilizer fertilizer = MFRRegistry.getFertilizers().get(new Integer(fertStack.itemID));
        IFactoryFertilizable fertilizable = MFRRegistry.getFertilizables().get(new Integer(targetId));
        if (fertilizer.getFertilizerMeta() != fertStack.getItemDamage()) {
            continue;
        }
        if (!fertilizable.canFertilizeBlock(worldObj, bp.x, bp.y, bp.z, fertilizer.getFertilizerType())) {
            continue;
        }
        if (fertilizable.fertilize(worldObj, _rand, bp.x, bp.y, bp.z, fertilizer.getFertilizerType())) {
            fertilizer.consume(fertStack);
            if (fertStack.stackSize <= 0) {
                setInventorySlotContents(stackIndex, null);
            }
            return true;
        }
    }
    setIdleTicks(getIdleTicksMax());
    return false;
}
Also used : IFactoryFertilizable(powercrystals.minefactoryreloaded.api.IFactoryFertilizable) BlockPosition(powercrystals.core.position.BlockPosition) ItemStack(net.minecraft.item.ItemStack) IFactoryFertilizer(powercrystals.minefactoryreloaded.api.IFactoryFertilizer)

Example 8 with BlockPosition

use of powercrystals.core.position.BlockPosition in project MineFactoryReloaded by powercrystals.

the class TileEntityFisher method activateMachine.

@Override
public boolean activateMachine() {
    if (_isJammed || worldObj.getWorldTime() % 137 == 0) {
        Area fishingHole = _ham.getHarvestArea();
        for (BlockPosition bp : fishingHole.getPositionsBottomFirst()) {
            if (worldObj.getBlockId(bp.x, bp.y, bp.z) != Block.waterStill.blockID) {
                _isJammed = true;
                setIdleTicks(getIdleTicksMax());
                return false;
            }
        }
    }
    _isJammed = false;
    setWorkDone(getWorkDone() + 1);
    if (getWorkDone() > getWorkMax()) {
        doDrop(new ItemStack(Item.fishRaw));
        setWorkDone(0);
    }
    return true;
}
Also used : Area(powercrystals.core.position.Area) BlockPosition(powercrystals.core.position.BlockPosition) ItemStack(net.minecraft.item.ItemStack)

Example 9 with BlockPosition

use of powercrystals.core.position.BlockPosition in project MineFactoryReloaded by powercrystals.

the class TileEntityFruitPicker method getNextTreeSegment.

private BlockPosition getNextTreeSegment(int x, int y, int z, boolean treeFlipped) {
    int blockId;
    if (_lastTree == null || _lastTree.x != x || _lastTree.y != y || _lastTree.z != z) {
        int yTreeAreaLowerBound = (treeFlipped ? y - MFRConfig.fruitTreeSearchMaxVertical.getInt() : y);
        int yTreeAreaUpperBound = (treeFlipped ? y : y + MFRConfig.fruitTreeSearchMaxVertical.getInt());
        Area a = new Area(x - MFRConfig.fruitTreeSearchMaxHorizontal.getInt(), x + MFRConfig.fruitTreeSearchMaxHorizontal.getInt(), yTreeAreaLowerBound, yTreeAreaUpperBound, z - MFRConfig.fruitTreeSearchMaxHorizontal.getInt(), z + MFRConfig.fruitTreeSearchMaxHorizontal.getInt());
        _treeManager = new TreeHarvestManager(a, treeFlipped ? TreeHarvestMode.HarvestInverted : TreeHarvestMode.Harvest);
        _lastTree = new BlockPosition(x, y, z);
    } else if (_treeManager.getIsDone()) {
        _treeManager.reset();
    }
    while (true) {
        if (_treeManager.getIsDone()) {
            return null;
        }
        BlockPosition bp = _treeManager.getNextBlock();
        blockId = worldObj.getBlockId(bp.x, bp.y, bp.z);
        if (MFRRegistry.getFruits().containsKey(new Integer(blockId)) && MFRRegistry.getFruits().get(new Integer(blockId)).canBePicked(worldObj, bp.x, bp.y, bp.z)) {
            return bp;
        }
        _treeManager.moveNext();
    }
}
Also used : Area(powercrystals.core.position.Area) BlockPosition(powercrystals.core.position.BlockPosition) TreeHarvestManager(powercrystals.minefactoryreloaded.core.TreeHarvestManager)

Example 10 with BlockPosition

use of powercrystals.core.position.BlockPosition in project MineFactoryReloaded by powercrystals.

the class BlockRedNetCable method isProvidingStrongPower.

@Override
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) {
    int power = 0;
    TileEntity te = world.getBlockTileEntity(x, y, z);
    if (te instanceof TileEntityRedNetCable) {
        TileEntityRedNetCable cable = ((TileEntityRedNetCable) te);
        if (cable.getNetwork() == null || cable.getConnectionState(ForgeDirection.VALID_DIRECTIONS[side].getOpposite()) == RedNetConnectionType.None) {
            return 0;
        }
        BlockPosition nodebp = new BlockPosition(x, y, z, ForgeDirection.getOrientation(side).getOpposite());
        nodebp.moveForwards(1);
        int subnet = cable.getSideColor(nodebp.orientation);
        if (cable.getNetwork().isWeakNode(nodebp)) {
            power = 0;
            RedstoneNetwork.log("Asked for strong power at " + x + "," + y + "," + z + " - weak node, power 0");
        } else {
            power = Math.min(Math.max(cable.getNetwork().getPowerLevelOutput(subnet), 0), 15);
            RedstoneNetwork.log("Asked for strong power at " + x + "," + y + "," + z + " - got " + power + " from network " + ((TileEntityRedNetCable) te).getNetwork().getId() + ":" + subnet);
        }
    }
    return power;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockPosition(powercrystals.core.position.BlockPosition) TileEntityRedNetCable(powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable)

Aggregations

BlockPosition (powercrystals.core.position.BlockPosition)37 ItemStack (net.minecraft.item.ItemStack)8 TileEntity (net.minecraft.tileentity.TileEntity)8 Area (powercrystals.core.position.Area)6 Block (net.minecraft.block.Block)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ForgeDirection (net.minecraftforge.common.ForgeDirection)2 IFactoryHarvestable (powercrystals.minefactoryreloaded.api.IFactoryHarvestable)2 IConnectableRedNet (powercrystals.minefactoryreloaded.api.rednet.IConnectableRedNet)2 TreeHarvestManager (powercrystals.minefactoryreloaded.core.TreeHarvestManager)2 IconOverlay (powercrystals.minefactoryreloaded.render.IconOverlay)2 TileEntityRedNetCable (powercrystals.minefactoryreloaded.tile.rednet.TileEntityRedNetCable)2 IPowerProvider (buildcraft.api.power.IPowerProvider)1 IPowerReceptor (buildcraft.api.power.IPowerReceptor)1 ArrayList (java.util.ArrayList)1 Entity (net.minecraft.entity.Entity)1 EntityAgeable (net.minecraft.entity.EntityAgeable)1 EntityLiving (net.minecraft.entity.EntityLiving)1 EntityMinecartContainer (net.minecraft.entity.item.EntityMinecartContainer)1