Search in sources :

Example 1 with ConnectType

use of mods.railcraft.api.charge.IElectricGrid.ChargeHandler.ConnectType in project Railcraft by Railcraft.

the class GridTools method getMutuallyConnectedObjects.

public static Set<IElectricGrid> getMutuallyConnectedObjects(IElectricGrid gridObject) {
    Set<IElectricGrid> connectedObjects = new HashSet<IElectricGrid>();
    WorldCoordinate myPos = new WorldCoordinate(gridObject.getTile());
    for (Map.Entry<BlockPos, EnumSet<ConnectType>> position : gridObject.getChargeHandler().getPossibleConnectionLocations().entrySet()) {
        Optional<IElectricGrid> otherObj = getGridObjectAt(gridObject.getTile().getWorld(), position.getKey());
        if (otherObj.isPresent() && position.getValue().contains(otherObj.get().getChargeHandler().getType())) {
            EnumSet<ConnectType> otherType = otherObj.get().getChargeHandler().getPossibleConnectionLocations().get(myPos);
            if (otherType != null && otherType.contains(gridObject.getChargeHandler().getType()))
                connectedObjects.add(otherObj.get());
        }
    }
    return connectedObjects;
}
Also used : WorldCoordinate(mods.railcraft.api.core.WorldCoordinate) EnumSet(java.util.EnumSet) BlockPos(net.minecraft.util.math.BlockPos) Map(java.util.Map) HashSet(java.util.HashSet) ConnectType(mods.railcraft.api.charge.IElectricGrid.ChargeHandler.ConnectType)

Aggregations

EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ConnectType (mods.railcraft.api.charge.IElectricGrid.ChargeHandler.ConnectType)1 WorldCoordinate (mods.railcraft.api.core.WorldCoordinate)1 BlockPos (net.minecraft.util.math.BlockPos)1