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