Search in sources :

Example 1 with ISidedPneumaticMachine

use of pneumaticCraft.api.tileentity.ISidedPneumaticMachine in project PneumaticCraft by MineMaarten.

the class TileEntityPressureTube method updateConnections.

public void updateConnections(World world, int x, int y, int z) {
    sidesConnected = new boolean[6];
    boolean hasModule = false;
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        TileEntity te = getTileCache()[direction.ordinal()].getTileEntity();
        IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
        if (machine != null) {
            sidesConnected[direction.ordinal()] = isConnectedTo(direction) && machine.isConnectedTo(direction.getOpposite());
        } else if (te instanceof ISidedPneumaticMachine) {
            sidesConnected[direction.ordinal()] = ((ISidedPneumaticMachine) te).getAirHandler(direction.getOpposite()) != null;
        }
        if (modules[direction.ordinal()] != null) {
            hasModule = true;
        }
    }
    int sidesCount = 0;
    for (boolean bool : sidesConnected) {
        if (bool)
            sidesCount++;
    }
    if (sidesCount == 1 && !hasModule) {
        for (int i = 0; i < 6; i++) {
            if (sidesConnected[i]) {
                if (isConnectedTo(ForgeDirection.getOrientation(i).getOpposite()))
                    sidesConnected[i ^ 1] = true;
                break;
            }
        }
    }
    for (int i = 0; i < 6; i++) {
        if (modules[i] != null && modules[i].isInline())
            sidesConnected[i] = false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISidedPneumaticMachine(pneumaticCraft.api.tileentity.ISidedPneumaticMachine)

Example 2 with ISidedPneumaticMachine

use of pneumaticCraft.api.tileentity.ISidedPneumaticMachine in project PneumaticCraft by MineMaarten.

the class TileEntityVacuumPump method getConnectedPneumatics.

@Override
public List<Pair<ForgeDirection, IAirHandler>> getConnectedPneumatics() {
    List<Pair<ForgeDirection, IAirHandler>> teList = new ArrayList<Pair<ForgeDirection, IAirHandler>>();
    ForgeDirection direction = getInputSide();
    TileEntity te = getTileCache()[direction.ordinal()].getTileEntity();
    IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
    if (machine != null && isConnectedTo(direction) && machine.isConnectedTo(direction.getOpposite())) {
        teList.add(new ImmutablePair(direction, machine.getAirHandler()));
    } else if (te instanceof ISidedPneumaticMachine) {
        IAirHandler handler = ((ISidedPneumaticMachine) te).getAirHandler(direction);
        if (handler != null) {
            teList.add(new ImmutablePair(direction, handler));
        }
    }
    return teList;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IAirHandler(pneumaticCraft.api.tileentity.IAirHandler) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) ArrayList(java.util.ArrayList) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISidedPneumaticMachine(pneumaticCraft.api.tileentity.ISidedPneumaticMachine) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Example 3 with ISidedPneumaticMachine

use of pneumaticCraft.api.tileentity.ISidedPneumaticMachine in project PneumaticCraft by MineMaarten.

the class TileEntityPneumaticBase method getConnectedPneumatics.

/**
 * Retrieves a list of all the connecting pneumatics. It takes sides in account.
 * @return
 */
@Override
public List<Pair<ForgeDirection, IAirHandler>> getConnectedPneumatics() {
    List<Pair<ForgeDirection, IAirHandler>> teList = new ArrayList<Pair<ForgeDirection, IAirHandler>>();
    for (IAirHandler specialConnection : specialConnectedHandlers) {
        teList.add(new ImmutablePair(ForgeDirection.UNKNOWN, specialConnection));
    }
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        TileEntity te = getTileCache()[direction.ordinal()].getTileEntity();
        IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
        if (machine != null && isConnectedTo(direction) && machine.isConnectedTo(direction.getOpposite())) {
            teList.add(new ImmutablePair(direction, machine.getAirHandler()));
        } else if (te instanceof ISidedPneumaticMachine) {
            IAirHandler handler = ((ISidedPneumaticMachine) te).getAirHandler(direction.getOpposite());
            if (handler != null) {
                teList.add(new ImmutablePair(direction, handler));
            }
        }
    }
    return teList;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IAirHandler(pneumaticCraft.api.tileentity.IAirHandler) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) ArrayList(java.util.ArrayList) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISidedPneumaticMachine(pneumaticCraft.api.tileentity.ISidedPneumaticMachine) MutablePair(org.apache.commons.lang3.tuple.MutablePair) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 IPneumaticMachine (pneumaticCraft.api.tileentity.IPneumaticMachine)3 ISidedPneumaticMachine (pneumaticCraft.api.tileentity.ISidedPneumaticMachine)3 ArrayList (java.util.ArrayList)2 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)2 Pair (org.apache.commons.lang3.tuple.Pair)2 IAirHandler (pneumaticCraft.api.tileentity.IAirHandler)2 MutablePair (org.apache.commons.lang3.tuple.MutablePair)1