Example #1
0
def create_circuit(asic, coords):
    block = factory.world.sync_get_block(coords)
    metadata = factory.world.sync_get_metadata(coords)

    cls = block_to_circuit.get(block, PlainBlock)

    circuit = cls(coords, block, metadata)
    circuit.connect(asic)

    return circuit
Example #2
0
def create_circuit(asic, coords):
    block = factory.world.sync_get_block(coords)
    metadata = factory.world.sync_get_metadata(coords)

    cls = block_to_circuit.get(block, PlainBlock)

    circuit = cls(coords, block, metadata)

    # What I'm about to do probably seems a bit, well, extravagant, but until
    # the real cause can properly be dissected, it's the right thing to do,
    # and maybe in general, it's the right thing.
    # Try to connect the circuit. If it fails, disconnect the current circuit
    # on the asic, and try again.
    try:
        circuit.connect(asic)
    except RedstoneError:
        asic.circuits[coords].disconnect(asic)
        circuit.connect(asic)

    return circuit