Search in sources :

Example 6 with IRedstoneDevice

use of com.bluepowermod.api.wire.redstone.IRedstoneDevice in project BluePower by Qmunity.

the class BundledPropagator method propagate.

@Override
public void propagate() {
    if ((device instanceof IPart && ((IPart) device).getParent() == null) || device.getWorld() == null)
        return;
    for (MinecraftColor c : MinecraftColor.VALID_COLORS) {
        IRedstoneDevice dev;
        if (device instanceof IInsulatedRedwire) {
            dev = (IRedstoneDevice) device;
        } else {
            dev = BundledDeviceWrapper.wrap(device, c);
        }
        if (dev == null)
            continue;
        RedstoneApi.getInstance().getRedstonePropagator(dev, side).propagate();
    }
}
Also used : MinecraftColor(com.bluepowermod.api.misc.MinecraftColor) IInsulatedRedwire(com.bluepowermod.api.wire.redstone.IRedwire.IInsulatedRedwire) IPart(uk.co.qmunity.lib.part.IPart) IRedstoneDevice(com.bluepowermod.api.wire.redstone.IRedstoneDevice)

Example 7 with IRedstoneDevice

use of com.bluepowermod.api.wire.redstone.IRedstoneDevice 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

IRedstoneDevice (com.bluepowermod.api.wire.redstone.IRedstoneDevice)7 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 IConnection (com.bluepowermod.api.connect.IConnection)2 IPart (uk.co.qmunity.lib.part.IPart)2 IConnectionCache (com.bluepowermod.api.connect.IConnectionCache)1 MinecraftColor (com.bluepowermod.api.misc.MinecraftColor)1 IInsulatedRedwire (com.bluepowermod.api.wire.redstone.IRedwire.IInsulatedRedwire)1 IWirelessDevice (com.bluepowermod.api.wireless.IWirelessDevice)1 BPPartFaceRotate (com.bluepowermod.part.BPPartFaceRotate)1 DummyRedstoneDevice (com.bluepowermod.redstone.DummyRedstoneDevice)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 Pair (uk.co.qmunity.lib.misc.Pair)1 Vec3d (uk.co.qmunity.lib.vec.Vec3d)1