Search in sources :

Example 1 with IConnection

use of com.bluepowermod.api.connect.IConnection in project BluePower by Qmunity.

the class GateTransceiver method propagate.

@Override
public Collection<Entry<IConnection<IRedstoneDevice>, Boolean>> propagate(ForgeDirection fromSide) {
    List<Entry<IConnection<IRedstoneDevice>, Boolean>> l = new ArrayList<Entry<IConnection<IRedstoneDevice>, Boolean>>();
    if (frequency == null)
        return l;
    l.add(new Pair<IConnection<IRedstoneDevice>, Boolean>(getRedstoneConnectionCache().getConnectionOnSide(fromSide), false));
    for (IWirelessDevice d : WirelessManager.COMMON_INSTANCE.getDevices()) {
        if (d != this && d.getFrequency() != null && d.getFrequency().equals(getFrequency())) {
            if (d instanceof GateTransceiver) {
                IConnection<IRedstoneDevice> c = ((GateTransceiver) d).getRedstoneConnectionCache().getConnectionOnSide(((GateTransceiver) d).front().getForgeDirection());
                if (c != null)
                    l.add(new Pair<IConnection<IRedstoneDevice>, Boolean>(c, false));
            }
        }
    }
    return l;
}
Also used : Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) IConnection(com.bluepowermod.api.connect.IConnection) IRedstoneDevice(com.bluepowermod.api.wire.redstone.IRedstoneDevice) IWirelessDevice(com.bluepowermod.api.wireless.IWirelessDevice) Pair(uk.co.qmunity.lib.misc.Pair)

Example 2 with IConnection

use of com.bluepowermod.api.connect.IConnection in project BluePower by Qmunity.

the class BundledConnectionCache method recalculateConnections.

@SuppressWarnings("unchecked")
@Override
public void recalculateConnections() {
    if (dev.getWorld().isRemote)
        return;
    IBundledDevice self = getSelf();
    for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        boolean wasConnected = connections[d.ordinal()] != null;
        BundledConnection con = RedConnectionHelper.getBundledNeighbor(self, d);
        if (con != null) {
            if (!wasConnected || connections[d.ordinal()].getB() != con.getB() || connections[d.ordinal()].getSideB() != con.getSideB() || connections[d.ordinal()].getType() != con.getType()) {
                onConnect(con.getSideA(), con.getB(), con.getSideB(), con.getType());
                ((IConnectionCache<IBundledDevice>) con.getB().getBundledConnectionCache()).onConnect(con.getSideB(), con.getA(), con.getSideA(), con.getType());
                IConnection<IBundledDevice> con2 = (IConnection<IBundledDevice>) con.getB().getBundledConnectionCache().getConnectionOnSide(con.getSideB());
                con = connections[d.ordinal()];
                if (con == null)
                    return;
                con.setComplementaryConnection(con2);
                con2.setComplementaryConnection(con);
            }
        } else if (wasConnected) {
            con = connections[d.ordinal()];
            if (con != null) {
                onDisconnect(con.getSideA());
                con.getB().getBundledConnectionCache().onDisconnect(con.getSideB());
            }
        }
    }
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IConnection(com.bluepowermod.api.connect.IConnection) IConnectionCache(com.bluepowermod.api.connect.IConnectionCache) IBundledDevice(com.bluepowermod.api.wire.redstone.IBundledDevice)

Example 3 with IConnection

use of com.bluepowermod.api.connect.IConnection in project BluePower by Qmunity.

the class RedstoneConnectionCache method recalculateConnections.

@SuppressWarnings("unchecked")
@Override
public void recalculateConnections() {
    if (dev.getWorld().isRemote)
        return;
    IRedstoneDevice self = getSelf();
    for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        boolean wasConnected = connections[d.ordinal()] != null;
        RedstoneConnection con = RedConnectionHelper.getNeighbor(self, d);
        if (con != null) {
            if (!wasConnected || connections[d.ordinal()].getB() != con.getB() || connections[d.ordinal()].getSideB() != con.getSideB() || connections[d.ordinal()].getType() != con.getType()) {
                onConnect(con.getSideA(), con.getB(), con.getSideB(), con.getType());
                ((IConnectionCache<IRedstoneDevice>) con.getB().getRedstoneConnectionCache()).onConnect(con.getSideB(), con.getA(), con.getSideA(), con.getType());
                IConnection<IRedstoneDevice> con2 = (IConnection<IRedstoneDevice>) con.getB().getRedstoneConnectionCache().getConnectionOnSide(con.getSideB());
                con = connections[d.ordinal()];
                if (con == null)
                    return;
                con.setComplementaryConnection(con2);
                con2.setComplementaryConnection(con);
            }
        } else if (wasConnected) {
            con = connections[d.ordinal()];
            if (con != null) {
                onDisconnect(con.getSideA());
                con.getB().getRedstoneConnectionCache().onDisconnect(con.getSideB());
            }
        }
    }
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IConnection(com.bluepowermod.api.connect.IConnection) IRedstoneDevice(com.bluepowermod.api.wire.redstone.IRedstoneDevice) IConnectionCache(com.bluepowermod.api.connect.IConnectionCache)

Aggregations

IConnection (com.bluepowermod.api.connect.IConnection)3 IConnectionCache (com.bluepowermod.api.connect.IConnectionCache)2 IRedstoneDevice (com.bluepowermod.api.wire.redstone.IRedstoneDevice)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 IBundledDevice (com.bluepowermod.api.wire.redstone.IBundledDevice)1 IWirelessDevice (com.bluepowermod.api.wireless.IWirelessDevice)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 Pair (uk.co.qmunity.lib.misc.Pair)1