Search in sources :

Example 1 with IBundledDevice

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

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

the class GateIntegratedCircuit method getBundledDeviceOnSide.

@Override
public IBundledDevice getBundledDeviceOnSide(ForgeDirection side) {
    side = new Vec3d(0, 0, 0).add(side).rotate(0, 90 * -getRotation(), 0).toForgeDirection();
    IPart p = getCircuitPartOnSide(side);
    if (p == null)
        return null;
    if (p instanceof IBundledDevice)
        return (IBundledDevice) p;
    return null;
}
Also used : IPart(uk.co.qmunity.lib.part.IPart) Vec3d(uk.co.qmunity.lib.vec.Vec3d) IBundledDevice(com.bluepowermod.api.wire.redstone.IBundledDevice)

Aggregations

IBundledDevice (com.bluepowermod.api.wire.redstone.IBundledDevice)2 IConnection (com.bluepowermod.api.connect.IConnection)1 IConnectionCache (com.bluepowermod.api.connect.IConnectionCache)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 IPart (uk.co.qmunity.lib.part.IPart)1 Vec3d (uk.co.qmunity.lib.vec.Vec3d)1