⏱️ 예상 읽기 시간: 20분

서론

마인크래프트의 ComputerCraft와 Create 모드는 각각 프로그래밍과 기계 공학의 즐거움을 제공하지만, 두 모드 간의 연결은 제한적이었습니다. CC:C Bridge는 이러한 한계를 완전히 해결하여 ComputerCraft의 정밀한 제어와 Create의 강력한 기계들을 완벽하게 통합합니다.

이 모드를 통해 Lua 스크립트로 Create의 기계들을 세밀하게 모니터링하고 제어할 수 있으며, 컴퓨터의 정보를 다양한 디스플레이에 표시하고, 애니메트로닉을 통해 표현력 있는 로봇을 만들 수 있습니다.

CC:C Bridge 개요

핵심 기능과 특징

🔌 확장된 주변 장치 (Peripherals)

  • Source Block: Create 기계의 정보를 컴퓨터로 전송
  • Target Block: 컴퓨터의 데이터를 Create 디스플레이로 출력
  • Animatronic: 프로그래밍 가능한 애니메이션 로봇
  • RedRouter: 레드스톤 신호를 케이블로 라우팅

💻 정밀한 모니터링

  • Stress Units (SU) 실시간 측정
  • 회전 속도 (RPM) 모니터링
  • 기계 상태 및 성능 추적
  • 인벤토리 및 유체 레벨 확인

🎮 인터랙티브 디스플레이

  • Flip Display 제어
  • Nixie Tube 숫자 표시
  • Lectern 정보 업데이트
  • Sign 텍스트 동적 변경

🤖 애니메이션 제어

  • 로봇 퍼펫 애니메이션
  • 감정 표현 시스템
  • 사용자 정의 동작 패턴
  • 실시간 인터랙션

시스템 요구사항 및 설치

필요한 모드

마인크래프트 버전: 1.19.2, 1.20.1, 1.21.1
모드 로더: Forge / NeoForge / Fabric

필수 모드:
- CC: Tweaked (ComputerCraft)
- Create
- CC:C Bridge

권장 모드:
- JEI (Just Enough Items)
- WAILA/HWYLA (블록 정보 표시)

설치 방법

CurseForge를 통한 설치

1. CurseForge 앱 실행
2. "CC:C Bridge" 검색
3. 해당하는 마인크래프트 버전 선택
4. Install 클릭
5. Dependencies 자동 설치 확인

수동 설치

# 1. 모드 파일 다운로드
# GitHub Releases에서 최신 버전 다운로드
wget https://github.com/tweaked-programs/cccbridge/releases/latest

# 2. mods 폴더에 배치
minecraft/
├── mods/
│   ├── cc-tweaked-[version].jar
│   ├── create-[version].jar
│   └── cccbridge-[version].jar
└── ...

개발 환경 설정 (고급 사용자)

# 소스 코드 클론
git clone https://github.com/tweaked-programs/cccbridge.git
cd cccbridge

# Gradle 빌드
./gradlew build

# 개발 환경 실행
./gradlew runClient

기본 블록 및 아이템

1. Source Block (소스 블록)

Create 기계의 정보를 ComputerCraft 컴퓨터로 전송하는 핵심 블록입니다.

제작법

[ C ] [ R ] [ C ]
[ R ] [ O ] [ R ]
[ C ] [ R ] [ C ]

C = Copper Ingot
R = Redstone
O = Observer

연결 방법

-- 소스 블록을 컴퓨터에 연결
local source = peripheral.find("cccbridge:source")
if source then
    print("Source Block 연결됨!")
else
    print("Source Block을 찾을 수 없습니다.")
end

기본 사용법

-- Create 기계 정보 수집
local function getCreateMachineInfo()
    local source = peripheral.find("cccbridge:source")
    if not source then
        return nil
    end
    
    -- 연결된 Create 블록들의 정보 가져오기
    local connectedBlocks = source.getConnectedBlocks()
    
    for i, block in ipairs(connectedBlocks) do
        print("블록 " .. i .. ": " .. block.name)
        print("위치: " .. block.x .. ", " .. block.y .. ", " .. block.z)
        
        -- 블록별 정보 확인
        if block.hasStress then
            print("스트레스: " .. block.stress .. " SU")
            print("용량: " .. block.stressCapacity .. " SU")
        end
        
        if block.hasRotation then
            print("회전 속도: " .. block.speed .. " RPM")
        end
    end
    
    return connectedBlocks
end

2. Target Block (타겟 블록)

컴퓨터의 데이터를 Create의 디스플레이 장치들로 출력하는 블록입니다.

제작법

[ C ] [ G ] [ C ]
[ G ] [ D ] [ G ]
[ C ] [ G ] [ C ]

C = Copper Ingot
G = Glass
D = Dispenser

지원하는 디스플레이

  • Flip Display (텍스트 표시)
  • Nixie Tube (숫자 표시)
  • Lectern (책 내용 업데이트)
  • Sign (표지판 텍스트)

사용 예시

-- 타겟 블록을 통한 디스플레이 제어
local function updateDisplays()
    local target = peripheral.find("cccbridge:target")
    if not target then
        print("Target Block을 찾을 수 없습니다.")
        return
    end
    
    -- 현재 시간을 Flip Display에 표시
    local currentTime = os.date("%H:%M:%S")
    target.setFlipDisplayText("current_time", currentTime)
    
    -- 생산량을 Nixie Tube에 표시
    local production = getProductionCount()
    target.setNixieTubeValue("production_counter", production)
    
    -- 시스템 상태를 Sign에 표시
    local status = getSystemStatus()
    target.setSignText("status_sign", {
        "시스템 상태",
        status,
        "마지막 업데이트:",
        currentTime
    })
end

3. Animatronic (애니메트로닉)

프로그래밍 가능한 애니메이션 로봇으로, 표현력 있는 동작을 만들 수 있습니다.

제작법

[ I ] [ H ] [ I ]
[ A ] [ C ] [ A ]
[ I ] [ R ] [ I ]

I = Iron Ingot
H = Head (any mob head)
A = Armor (any armor piece)
C = Chest
R = Redstone Block

기본 애니메이션 제어

-- 애니메트로닉 기본 제어
local function controlAnimatronic()
    local animatronic = peripheral.find("cccbridge:animatronic")
    if not animatronic then
        print("Animatronic을 찾을 수 없습니다.")
        return
    end
    
    -- 기본 동작들
    animatronic.wave()              -- 손 흔들기
    animatronic.nod()               -- 고개 끄덕이기
    animatronic.shake()             -- 고개 젓기
    animatronic.dance()             -- 춤추기
    animatronic.bow()               -- 인사하기
    
    -- 커스텀 애니메이션
    animatronic.setHeadRotation(45, 0)  -- 머리 회전 (yaw, pitch)
    animatronic.setArmPosition("left", 90)  -- 팔 위치 조절
    animatronic.setArmPosition("right", -90)
    
    -- 감정 표현
    animatronic.setEmotion("happy")     -- 기쁨
    animatronic.setEmotion("sad")       -- 슬픔
    animatronic.setEmotion("surprised") -- 놀람
    animatronic.setEmotion("angry")     -- 화남
end

고급 애니메이션 시퀀스

-- 복잡한 애니메이션 시퀀스 제작
local function createAnimationSequence()
    local animatronic = peripheral.find("cccbridge:animatronic")
    
    -- 애니메이션 시퀀스 정의
    local sequence = {
        {action = "setEmotion", params = {"neutral"}, duration = 1},
        {action = "wave", params = {}, duration = 2},
        {action = "setHeadRotation", params = {30, 10}, duration = 1},
        {action = "setEmotion", params = {"happy"}, duration = 2},
        {action = "dance", params = {}, duration = 5},
        {action = "bow", params = {}, duration = 3},
        {action = "setEmotion", params = {"neutral"}, duration = 1}
    }
    
    -- 시퀀스 실행
    for i, step in ipairs(sequence) do
        animatronic[step.action](table.unpack(step.params))
        sleep(step.duration)
    end
end

-- 인터랙티브 모드
local function interactiveMode()
    local animatronic = peripheral.find("cccbridge:animatronic")
    
    while true do
        local event, side, x, y, z, player = os.pullEvent("player_interact")
        
        if player then
            -- 플레이어별 인사
            animatronic.setEmotion("happy")
            animatronic.wave()
            
            -- 플레이어 이름에 따른 반응
            if player == "admin" then
                animatronic.bow()
            elseif player == "friend" then
                animatronic.dance()
            else
                animatronic.nod()
            end
            
            sleep(2)
            animatronic.setEmotion("neutral")
        end
    end
end

4. RedRouter (레드라우터)

레드스톤 신호를 케이블을 통해 장거리 전송할 수 있는 혁신적인 블록입니다.

제작법

[ R ] [ C ] [ R ]
[ C ] [ R ] [ C ]
[ R ] [ C ] [ R ]

R = Redstone
C = Copper Ingot

기본 케이블 연결

-- RedRouter 설정 및 제어
local function setupRedRouter()
    local router = peripheral.find("cccbridge:red_router")
    if not router then
        print("RedRouter를 찾을 수 없습니다.")
        return
    end
    
    -- 채널 설정 (1-16)
    router.setChannel(1, true)   -- 채널 1 활성화
    router.setChannel(2, false)  -- 채널 2 비활성화
    
    -- 신호 전송
    router.transmit(1, "motor_control", true)   -- 채널 1로 신호 전송
    router.transmit(2, "light_system", false)   -- 채널 2로 신호 전송
    
    -- 신호 수신
    local channel, label, signal = router.receive()
    print("수신: 채널 " .. channel .. ", 라벨: " .. label .. ", 신호: " .. tostring(signal))
end

네트워크 기반 제어 시스템

-- 복잡한 레드스톤 네트워크 구축
local RedNetwork = {}
RedNetwork.__index = RedNetwork

function RedNetwork.new()
    local self = setmetatable({}, RedNetwork)
    self.router = peripheral.find("cccbridge:red_router")
    self.channels = {}
    self.listeners = {}
    return self
end

function RedNetwork:addChannel(id, label)
    self.channels[id] = label
    self.router.setChannel(id, true)
end

function RedNetwork:sendSignal(channel, signal)
    if self.channels[channel] then
        self.router.transmit(channel, self.channels[channel], signal)
        print("신호 전송: " .. self.channels[channel] .. " -> " .. tostring(signal))
    end
end

function RedNetwork:addListener(channel, callback)
    if not self.listeners[channel] then
        self.listeners[channel] = {}
    end
    table.insert(self.listeners[channel], callback)
end

function RedNetwork:startListening()
    while true do
        local channel, label, signal = self.router.receive()
        if self.listeners[channel] then
            for _, callback in ipairs(self.listeners[channel]) do
                callback(signal, label)
            end
        end
    end
end

-- 사용 예시
local network = RedNetwork.new()
network:addChannel(1, "factory_control")
network:addChannel(2, "security_system")
network:addChannel(3, "lighting")

-- 리스너 추가
network:addListener(1, function(signal, label)
    print("공장 제어: " .. tostring(signal))
end)

network:addListener(2, function(signal, label)
    print("보안 시스템: " .. tostring(signal))
end)

실전 프로젝트: 자동화 시스템 구축

1. 스마트 팩토리 모니터링 시스템

Create 기계들을 실시간으로 모니터링하고 최적화하는 시스템을 구축해보겠습니다.

-- 스마트 팩토리 모니터링 시스템
local FactoryMonitor = {}
FactoryMonitor.__index = FactoryMonitor

function FactoryMonitor.new()
    local self = setmetatable({}, FactoryMonitor)
    self.source = peripheral.find("cccbridge:source")
    self.target = peripheral.find("cccbridge:target")
    self.animatronic = peripheral.find("cccbridge:animatronic")
    self.redRouter = peripheral.find("cccbridge:red_router")
    
    self.machines = {}
    self.alerts = {}
    self.productionStats = {
        totalItems = 0,
        itemsPerHour = 0,
        efficiency = 100,
        uptime = 0
    }
    
    return self
end

function FactoryMonitor:scanMachines()
    if not self.source then return end
    
    local connectedBlocks = self.source.getConnectedBlocks()
    self.machines = {}
    
    for i, block in ipairs(connectedBlocks) do
        local machine = {
            id = i,
            name = block.name,
            position = {x = block.x, y = block.y, z = block.z},
            status = "unknown",
            stress = block.stress or 0,
            stressCapacity = block.stressCapacity or 0,
            speed = block.speed or 0,
            efficiency = 0,
            lastUpdate = os.clock()
        }
        
        -- 기계 상태 분석
        if machine.stressCapacity > 0 then
            machine.efficiency = (1 - (machine.stress / machine.stressCapacity)) * 100
            if machine.efficiency < 20 then
                machine.status = "overloaded"
            elseif machine.efficiency > 80 then
                machine.status = "optimal"
            else
                machine.status = "normal"
            end
        end
        
        table.insert(self.machines, machine)
    end
end

function FactoryMonitor:checkAlerts()
    self.alerts = {}
    
    for _, machine in ipairs(self.machines) do
        if machine.status == "overloaded" then
            table.insert(self.alerts, {
                type = "warning",
                machine = machine.name,
                message = "기계 과부하 감지",
                severity = "high"
            })
        end
        
        if machine.speed < 10 and machine.speed > 0 then
            table.insert(self.alerts, {
                type = "info",
                machine = machine.name,
                message = "회전 속도 저하",
                severity = "medium"
            })
        end
    end
end

function FactoryMonitor:updateDisplays()
    if not self.target then return end
    
    -- 메인 상태 디스플레이
    local statusText = string.format(
        "팩토리 상태\n가동률: %.1f%%\n총 기계: %d\n알람: %d",
        self.productionStats.efficiency,
        #self.machines,
        #self.alerts
    )
    
    self.target.setFlipDisplayText("factory_status", statusText)
    
    -- 생산량 디스플레이
    self.target.setNixieTubeValue("production", self.productionStats.totalItems)
    
    -- 알람 표시
    if #self.alerts > 0 then
        local alertText = "⚠ 알람 ⚠"
        for _, alert in ipairs(self.alerts) do
            alertText = alertText .. "\n" .. alert.machine .. ": " .. alert.message
        end
        self.target.setSignText("alert_board", split(alertText, "\n"))
        
        -- 애니메트로닉으로 알람 표시
        if self.animatronic then
            self.animatronic.setEmotion("surprised")
            self.animatronic.wave()
        end
    else
        self.target.setSignText("alert_board", {"시스템 정상", "알람 없음", "", os.date("%H:%M:%S")})
        
        if self.animatronic then
            self.animatronic.setEmotion("happy")
        end
    end
end

function FactoryMonitor:optimizeProduction()
    -- 자동 최적화 로직
    for _, machine in ipairs(self.machines) do
        if machine.status == "overloaded" and self.redRouter then
            -- 과부하 기계의 속도 조절
            self.redRouter.transmit(1, "speed_control_" .. machine.id, false)
            print("기계 " .. machine.name .. " 속도 감소")
        elseif machine.efficiency > 90 and self.redRouter then
            -- 효율이 좋은 기계의 속도 증가
            self.redRouter.transmit(2, "speed_boost_" .. machine.id, true)
            print("기계 " .. machine.name .. " 속도 증가")
        end
    end
end

function FactoryMonitor:generateReport()
    local report = {
        timestamp = os.date("%Y-%m-%d %H:%M:%S"),
        totalMachines = #self.machines,
        activeAlerts = #self.alerts,
        averageEfficiency = 0,
        productionStats = self.productionStats
    }
    
    -- 평균 효율 계산
    local totalEfficiency = 0
    local machineCount = 0
    
    for _, machine in ipairs(self.machines) do
        if machine.efficiency > 0 then
            totalEfficiency = totalEfficiency + machine.efficiency
            machineCount = machineCount + 1
        end
    end
    
    if machineCount > 0 then
        report.averageEfficiency = totalEfficiency / machineCount
    end
    
    return report
end

function FactoryMonitor:run()
    print("스마트 팩토리 모니터링 시스템 시작")
    
    while true do
        -- 기계 스캔
        self:scanMachines()
        
        -- 알람 체크
        self:checkAlerts()
        
        -- 디스플레이 업데이트
        self:updateDisplays()
        
        -- 생산 최적화
        self:optimizeProduction()
        
        -- 보고서 생성 (매 시간)
        if os.clock() % 3600 < 5 then
            local report = self:generateReport()
            print("시간별 보고서: 효율 " .. string.format("%.1f%%", report.averageEfficiency))
        end
        
        sleep(5) -- 5초마다 업데이트
    end
end

-- 유틸리티 함수
function split(str, delimiter)
    local result = {}
    local pattern = "(.-)" .. delimiter
    local lastEnd = 1
    local s, e, cap = str:find(pattern, 1)
    
    while s do
        if s ~= 1 or cap ~= "" then
            table.insert(result, cap)
        end
        lastEnd = e + 1
        s, e, cap = str:find(pattern, lastEnd)
    end
    
    if lastEnd <= #str then
        cap = str:sub(lastEnd)
        table.insert(result, cap)
    end
    
    return result
end

-- 시스템 시작
local monitor = FactoryMonitor.new()
monitor:run()

2. 인터랙티브 로봇 도우미

애니메트로닉을 활용한 스마트 도우미 시스템을 만들어보겠습니다.

-- 인터랙티브 로봇 도우미 시스템
local RobotAssistant = {}
RobotAssistant.__index = RobotAssistant

function RobotAssistant.new(name)
    local self = setmetatable({}, RobotAssistant)
    self.name = name or "Robo"
    self.animatronic = peripheral.find("cccbridge:animatronic")
    self.target = peripheral.find("cccbridge:target")
    self.source = peripheral.find("cccbridge:source")
    
    self.mood = "neutral"
    self.energy = 100
    self.knowledge = {}
    self.schedule = {}
    self.interactions = 0
    
    -- 성격 특성
    self.personality = {
        friendliness = 8,   -- 1-10
        helpfulness = 9,    -- 1-10
        humor = 6,          -- 1-10
        curiosity = 7       -- 1-10
    }
    
    return self
end

function RobotAssistant:initialize()
    if self.animatronic then
        self.animatronic.setEmotion("happy")
        self.animatronic.wave()
        self:speak("안녕하세요! 저는 " .. self.name .. "입니다. 도움이 필요하시면 언제든 말씀하세요!")
    end
end

function RobotAssistant:speak(message)
    if self.target then
        self.target.setSignText("robot_speech", {
            self.name .. " 말:",
            message,
            "",
            os.date("%H:%M")
        })
    end
    print(self.name .. ": " .. message)
end

function RobotAssistant:setMood(newMood)
    self.mood = newMood
    if self.animatronic then
        self.animatronic.setEmotion(newMood)
    end
end

function RobotAssistant:reactToPlayer(playerName)
    self.interactions = self.interactions + 1
    
    -- 플레이어별 개인화된 반응
    if not self.knowledge[playerName] then
        self.knowledge[playerName] = {
            meetCount = 0,
            lastSeen = os.clock(),
            preference = "unknown",
            friendshipLevel = 1
        }
    end
    
    local playerData = self.knowledge[playerName]
    playerData.meetCount = playerData.meetCount + 1
    playerData.lastSeen = os.clock()
    
    -- 친밀도에 따른 반응
    if playerData.meetCount == 1 then
        self:setMood("curious")
        self:speak("처음 뵙겠습니다, " .. playerName .. "님! 반갑습니다.")
        if self.animatronic then
            self.animatronic.bow()
        end
    elseif playerData.meetCount < 5 then
        self:setMood("happy")
        self:speak("다시 만나게 되어 기쁩니다, " .. playerName .. "님!")
        if self.animatronic then
            self.animatronic.wave()
        end
    else
        self:setMood("happy")
        local greetings = {
            "오늘도 좋은 하루입니다, " .. playerName .. "님!",
            "어서 오세요! 무엇을 도와드릴까요?",
            "반갑습니다! 오늘 기분이 어떠신가요?"
        }
        self:speak(greetings[math.random(1, #greetings)])
        if self.animatronic then
            if math.random(1, 10) <= self.personality.humor then
                self.animatronic.dance()
            else
                self.animatronic.nod()
            end
        end
    end
    
    playerData.friendshipLevel = math.min(10, playerData.friendshipLevel + 0.1)
end

function RobotAssistant:checkFactoryStatus()
    if not self.source then
        self:speak("죄송합니다. 팩토리 센서에 접근할 수 없습니다.")
        return
    end
    
    local machines = self.source.getConnectedBlocks()
    local totalMachines = #machines
    local workingMachines = 0
    local totalStress = 0
    local totalCapacity = 0
    
    for _, machine in ipairs(machines) do
        if machine.speed and machine.speed > 0 then
            workingMachines = workingMachines + 1
        end
        if machine.stress then
            totalStress = totalStress + machine.stress
        end
        if machine.stressCapacity then
            totalCapacity = totalCapacity + machine.stressCapacity
        end
    end
    
    local efficiency = totalCapacity > 0 and (1 - totalStress / totalCapacity) * 100 or 0
    
    local statusMessage = string.format(
        "팩토리 상태 보고: 총 %d대 기계 중 %d대 가동 중. 효율: %.1f%%",
        totalMachines, workingMachines, efficiency
    )
    
    self:speak(statusMessage)
    
    if efficiency < 50 then
        self:setMood("surprised")
        self:speak("주의! 팩토리 효율이 낮습니다. 점검이 필요할 것 같습니다.")
        if self.animatronic then
            self.animatronic.shake()
        end
    elseif efficiency > 80 then
        self:setMood("happy")
        self:speak("훌륭합니다! 팩토리가 최적 상태로 운영되고 있습니다.")
    end
end

function RobotAssistant:giveAdvice()
    local advice = {
        "오늘도 창의적인 건축을 즐기세요!",
        "정기적으로 기계를 점검하는 것을 잊지 마세요.",
        "새로운 레드스톤 회로에 도전해보는 것은 어떨까요?",
        "충분한 휴식도 중요합니다. 가끔은 게임에서 벗어나세요.",
        "다른 플레이어들과 협력하면 더 멋진 것들을 만들 수 있습니다!"
    }
    
    local randomAdvice = advice[math.random(1, #advice)]
    self:speak(randomAdvice)
    
    if self.animatronic then
        self.animatronic.nod()
    end
end

function RobotAssistant:performDailyRoutine()
    local hour = tonumber(os.date("%H"))
    
    if hour == 8 then
        self:setMood("happy")
        self:speak("좋은 아침입니다! 새로운 하루를 시작해볼까요?")
        self:checkFactoryStatus()
    elseif hour == 12 then
        self:speak("점심시간입니다. 잠시 휴식을 취하시는 것이 어떨까요?")
        if self.animatronic then
            self.animatronic.setEmotion("relaxed")
        end
    elseif hour == 18 then
        self:speak("하루 수고하셨습니다! 오늘의 성과를 확인해보세요.")
        self:checkFactoryStatus()
    elseif hour == 22 then
        self:speak("늦은 시간입니다. 충분한 휴식을 취하시기 바랍니다.")
        self:setMood("sleepy")
    end
end

function RobotAssistant:respondToCommand(command, player)
    command = string.lower(command)
    
    if string.find(command, "상태") or string.find(command, "status") then
        self:checkFactoryStatus()
    elseif string.find(command, "안녕") or string.find(command, "hello") then
        self:reactToPlayer(player)
    elseif string.find(command, "조언") or string.find(command, "advice") then
        self:giveAdvice()
    elseif string.find(command, "춤") or string.find(command, "dance") then
        self:setMood("happy")
        self:speak("좋습니다! 함께 춤춰요!")
        if self.animatronic then
            self.animatronic.dance()
        end
    elseif string.find(command, "시간") or string.find(command, "time") then
        local currentTime = os.date("%H시 %M분")
        self:speak("현재 시간은 " .. currentTime .. "입니다.")
    else
        self:speak("죄송합니다. 이해하지 못했습니다. '상태', '조언', '춤', '시간' 같은 명령을 해보세요.")
        if self.animatronic then
            self.animatronic.shake()
        end
    end
end

function RobotAssistant:run()
    self:initialize()
    local lastRoutineHour = -1
    
    while true do
        -- 일일 루틴 체크
        local currentHour = tonumber(os.date("%H"))
        if currentHour ~= lastRoutineHour then
            self:performDailyRoutine()
            lastRoutineHour = currentHour
        end
        
        -- 에너지 관리
        self.energy = math.max(0, self.energy - 0.1)
        if self.energy < 20 then
            self:setMood("tired")
            if math.random(1, 100) == 1 then
                self:speak("조금 피곤합니다. 잠시 휴식을 취하겠습니다.")
                sleep(10)
                self.energy = math.min(100, self.energy + 30)
                self:setMood("neutral")
            end
        end
        
        -- 플레이어 상호작용 대기
        local event, side, x, y, z, player = os.pullEventRaw("player_interact")
        if event == "player_interact" and player then
            self.energy = math.min(100, self.energy + 5)
            self:reactToPlayer(player)
        end
        
        -- 채팅 명령 처리
        local event, player, message = os.pullEventRaw("chat")
        if event == "chat" and message then
            if string.find(string.lower(message), string.lower(self.name)) then
                local command = string.gsub(message, self.name, "")
                self:respondToCommand(command, player)
            end
        end
        
        sleep(1)
    end
end

-- 로봇 도우미 시작
local assistant = RobotAssistant.new("헬퍼봇")
assistant:run()

3. 레드스톤 네트워크 관리 시스템

RedRouter를 활용한 복잡한 레드스톤 네트워크를 구축해보겠습니다.

-- 레드스톤 네트워크 관리 시스템
local RedstoneNetwork = {}
RedstoneNetwork.__index = RedstoneNetwork

function RedstoneNetwork.new()
    local self = setmetatable({}, RedstoneNetwork)
    self.routers = {}
    self.channels = {}
    self.devices = {}
    self.schedules = {}
    self.rules = {}
    
    -- 네트워크 검색
    self:scanNetwork()
    
    return self
end

function RedstoneNetwork:scanNetwork()
    -- 모든 RedRouter 찾기
    local routerNames = peripheral.getNames()
    for _, name in ipairs(routerNames) do
        if peripheral.getType(name) == "cccbridge:red_router" then
            table.insert(self.routers, peripheral.wrap(name))
        end
    end
    
    print("발견된 RedRouter: " .. #self.routers .. "개")
end

function RedstoneNetwork:addDevice(id, name, type, channel, location)
    self.devices[id] = {
        name = name,
        type = type,
        channel = channel,
        location = location,
        state = false,
        lastToggle = 0,
        toggleCount = 0
    }
end

function RedstoneNetwork:addSchedule(deviceId, scheduleData)
    if not self.schedules[deviceId] then
        self.schedules[deviceId] = {}
    end
    table.insert(self.schedules[deviceId], scheduleData)
end

function RedstoneNetwork:addRule(condition, action)
    table.insert(self.rules, {
        condition = condition,
        action = action,
        enabled = true
    })
end

function RedstoneNetwork:transmitToDevice(deviceId, signal)
    local device = self.devices[deviceId]
    if not device then
        print("장치를 찾을 수 없습니다: " .. deviceId)
        return false
    end
    
    for _, router in ipairs(self.routers) do
        router.transmit(device.channel, device.name, signal)
    end
    
    device.state = signal
    device.lastToggle = os.clock()
    device.toggleCount = device.toggleCount + 1
    
    print(device.name .. " -> " .. tostring(signal))
    return true
end

function RedstoneNetwork:getDeviceState(deviceId)
    local device = self.devices[deviceId]
    return device and device.state or false
end

function RedstoneNetwork:processSchedules()
    local currentTime = os.date("*t")
    local currentMinute = currentTime.hour * 60 + currentTime.min
    
    for deviceId, scheduleList in pairs(self.schedules) do
        for _, schedule in ipairs(scheduleList) do
            if schedule.enabled then
                local scheduleMinute = schedule.hour * 60 + schedule.minute
                
                if currentMinute == scheduleMinute then
                    self:transmitToDevice(deviceId, schedule.state)
                    print("스케줄 실행: " .. deviceId .. " -> " .. tostring(schedule.state))
                end
            end
        end
    end
end

function RedstoneNetwork:processRules()
    for _, rule in ipairs(self.rules) do
        if rule.enabled and rule.condition() then
            rule.action()
        end
    end
end

function RedstoneNetwork:createSecuritySystem()
    -- 보안 시스템 장치 등록
    self:addDevice("main_door", "정문", "door", 1, {x=100, y=64, z=200})
    self:addDevice("security_lights", "보안등", "lighting", 2, {x=95, y=68, z=195})
    self:addDevice("alarm_system", "경보기", "alarm", 3, {x=105, y=65, z=205})
    self:addDevice("camera_system", "카메라", "camera", 4, {x=100, y=70, z=200})
    
    -- 보안 규칙 설정
    self:addRule(
        function() -- 조건: 밤 시간
            local hour = tonumber(os.date("%H"))
            return hour >= 20 or hour <= 6
        end,
        function() -- 액션: 보안 시스템 활성화
            self:transmitToDevice("security_lights", true)
            self:transmitToDevice("camera_system", true)
            print("야간 보안 모드 활성화")
        end
    )
    
    self:addRule(
        function() -- 조건: 침입 감지 (예시)
            -- 실제로는 센서 데이터를 확인
            return math.random(1, 1000) == 1
        end,
        function() -- 액션: 알람 시작
            self:transmitToDevice("alarm_system", true)
            self:transmitToDevice("security_lights", true)
            print("⚠ 침입 감지! 알람 활성화")
            
            -- 5초 후 알람 해제
            sleep(5)
            self:transmitToDevice("alarm_system", false)
        end
    )
end

function RedstoneNetwork:createLightingSystem()
    -- 조명 시스템 장치 등록
    self:addDevice("lobby_lights", "로비 조명", "lighting", 5, {x=0, y=64, z=0})
    self:addDevice("hallway_lights", "복도 조명", "lighting", 6, {x=10, y=64, z=0})
    self:addDevice("workshop_lights", "작업실 조명", "lighting", 7, {x=20, y=64, z=0})
    
    -- 자동 조명 스케줄
    self:addSchedule("lobby_lights", {hour=6, minute=0, state=true, enabled=true})
    self:addSchedule("lobby_lights", {hour=22, minute=0, state=false, enabled=true})
    
    self:addSchedule("workshop_lights", {hour=8, minute=0, state=true, enabled=true})
    self:addSchedule("workshop_lights", {hour=18, minute=0, state=false, enabled=true})
    
    -- 동적 조명 규칙
    self:addRule(
        function() -- 조건: 플레이어 근처
            -- 실제로는 플레이어 감지 센서 확인
            return math.random(1, 20) == 1
        end,
        function() -- 액션: 근처 조명 켜기
            self:transmitToDevice("hallway_lights", true)
            print("플레이어 감지 - 복도 조명 켜짐")
            
            -- 30초 후 자동 소등
            sleep(30)
            self:transmitToDevice("hallway_lights", false)
        end
    )
end

function RedstoneNetwork:createFactoryAutomation()
    -- 공장 자동화 장치 등록
    self:addDevice("conveyor_belt", "컨베이어 벨트", "mechanical", 8, {x=50, y=64, z=50})
    self:addDevice("item_sorter", "아이템 분류기", "mechanical", 9, {x=55, y=64, z=50})
    self:addDevice("furnace_array", "용광로 배열", "processing", 10, {x=60, y=64, z=50})
    self:addDevice("storage_system", "저장 시스템", "storage", 11, {x=65, y=64, z=50})
    
    -- 생산 라인 제어 규칙
    self:addRule(
        function() -- 조건: 저장소 가득참
            -- 실제로는 저장소 상태 확인
            return math.random(1, 100) <= 5
        end,
        function() -- 액션: 생산 라인 일시 정지
            self:transmitToDevice("conveyor_belt", false)
            self:transmitToDevice("furnace_array", false)
            print("저장소 포화 - 생산 라인 일시 정지")
            
            -- 60초 후 재가동
            sleep(60)
            self:transmitToDevice("conveyor_belt", true)
            self:transmitToDevice("furnace_array", true)
            print("생산 라인 재가동")
        end
    )
    
    -- 효율성 최적화 규칙
    self:addRule(
        function() -- 조건: 피크 시간
            local hour = tonumber(os.date("%H"))
            return hour >= 9 and hour <= 17
        end,
        function() -- 액션: 고속 모드
            self:transmitToDevice("conveyor_belt", true)
            self:transmitToDevice("item_sorter", true)
            self:transmitToDevice("furnace_array", true)
            print("피크 시간 - 고속 생산 모드")
        end
    )
end

function RedstoneNetwork:generateReport()
    print("\n=== 레드스톤 네트워크 상태 보고서 ===")
    print("라우터 수: " .. #self.routers)
    print("등록된 장치 수: " .. self:getDeviceCount())
    print("활성 스케줄 수: " .. self:getScheduleCount())
    print("활성 규칙 수: " .. self:getRuleCount())
    
    print("\n장치 상태:")
    for deviceId, device in pairs(self.devices) do
        print(string.format("  %s: %s (채널 %d, 토글 %d회)",
            device.name,
            device.state and "ON" or "OFF",
            device.channel,
            device.toggleCount
        ))
    end
end

function RedstoneNetwork:getDeviceCount()
    local count = 0
    for _ in pairs(self.devices) do
        count = count + 1
    end
    return count
end

function RedstoneNetwork:getScheduleCount()
    local count = 0
    for _, scheduleList in pairs(self.schedules) do
        for _, schedule in ipairs(scheduleList) do
            if schedule.enabled then
                count = count + 1
            end
        end
    end
    return count
end

function RedstoneNetwork:getRuleCount()
    local count = 0
    for _, rule in ipairs(self.rules) do
        if rule.enabled then
            count = count + 1
        end
    end
    return count
end

function RedstoneNetwork:run()
    print("레드스톤 네트워크 관리 시스템 시작")
    
    -- 시스템 초기화
    self:createSecuritySystem()
    self:createLightingSystem()
    self:createFactoryAutomation()
    
    local lastMinute = -1
    
    while true do
        local currentMinute = tonumber(os.date("%M"))
        
        -- 매분 스케줄 처리
        if currentMinute ~= lastMinute then
            self:processSchedules()
            lastMinute = currentMinute
        end
        
        -- 규칙 처리
        self:processRules()
        
        -- 매 시간 보고서 생성
        if currentMinute == 0 then
            self:generateReport()
        end
        
        sleep(1)
    end
end

-- 네트워크 시스템 시작
local network = RedstoneNetwork.new()
network:run()

성능 최적화 및 고급 팁

1. 메모리 및 성능 최적화

-- 메모리 효율적인 코드 작성
local function optimizeMemoryUsage()
    -- 전역 변수 최소화
    local localVar = "local is faster"
    
    -- 테이블 미리 할당
    local largeTable = {}
    for i = 1, 1000 do
        largeTable[i] = i
    end
    
    -- 가비지 컬렉션 관리
    collectgarbage("collect")
    
    -- 문자열 연결 최적화
    local strings = {}
    for i = 1, 100 do
        strings[i] = "string " .. i
    end
    local result = table.concat(strings, ", ")
end

-- 비동기 처리로 성능 향상
local function asyncProcessing()
    local tasks = {}
    
    -- 병렬 작업 추가
    table.insert(tasks, function()
        -- 기계 상태 모니터링
        return scanMachines()
    end)
    
    table.insert(tasks, function()
        -- 디스플레이 업데이트
        return updateDisplays()
    end)
    
    table.insert(tasks, function()
        -- 네트워크 통신
        return processNetworkMessages()
    end)
    
    -- 모든 작업을 병렬로 실행
    parallel.waitForAll(table.unpack(tasks))
end

2. 에러 처리 및 안정성

-- 안전한 주변장치 접근
local function safePeripheralAccess(peripheralType, operation)
    local peripheral = peripheral.find(peripheralType)
    if not peripheral then
        print("경고: " .. peripheralType .. " 주변장치를 찾을 수 없습니다.")
        return nil
    end
    
    local success, result = pcall(operation, peripheral)
    if not success then
        print("오류: " .. peripheralType .. " 작업 실패 - " .. result)
        return nil
    end
    
    return result
end

-- 네트워크 연결 복구
local function networkRecovery()
    local maxRetries = 3
    local retryDelay = 5
    
    for attempt = 1, maxRetries do
        local success = safePeripheralAccess("cccbridge:red_router", function(router)
            return router.transmit(1, "test", true)
        end)
        
        if success then
            print("네트워크 연결 복구됨")
            return true
        end
        
        print("네트워크 연결 시도 " .. attempt .. "/" .. maxRetries .. " 실패")
        sleep(retryDelay)
    end
    
    print("네트워크 연결 복구 실패")
    return false
end

3. 디버깅 및 로깅

-- 고급 로깅 시스템
local Logger = {}
Logger.__index = Logger

function Logger.new(filename)
    local self = setmetatable({}, Logger)
    self.filename = filename or "system.log"
    self.logLevel = "INFO"
    return self
end

function Logger:log(level, message)
    local timestamp = os.date("%Y-%m-%d %H:%M:%S")
    local logEntry = string.format("[%s] %s: %s", timestamp, level, message)
    
    print(logEntry)
    
    -- 파일에 로그 저장 (가능한 경우)
    local file = fs.open(self.filename, "a")
    if file then
        file.writeLine(logEntry)
        file.close()
    end
end

function Logger:info(message)
    self:log("INFO", message)
end

function Logger:warn(message)
    self:log("WARN", message)
end

function Logger:error(message)
    self:log("ERROR", message)
end

-- 성능 프로파일링
local function profileFunction(func, name)
    local startTime = os.clock()
    local result = func()
    local endTime = os.clock()
    
    print(string.format("함수 '%s' 실행 시간: %.3f초", name, endTime - startTime))
    return result
end

문제 해결 가이드

자주 발생하는 문제들

1. 주변장치 인식 실패

-- 해결 방법: 주변장치 재스캔
local function rescanPeripherals()
    print("주변장치 재스캔 중...")
    local peripherals = peripheral.getNames()
    
    for _, name in ipairs(peripherals) do
        local type = peripheral.getType(name)
        print("발견: " .. name .. " (" .. type .. ")")
    end
    
    sleep(2) -- 잠시 대기 후 재시도
end

2. 애니메트로닉 동작 불량

-- 해결 방법: 애니메트로닉 리셋
local function resetAnimatronic()
    local animatronic = peripheral.find("cccbridge:animatronic")
    if animatronic then
        animatronic.setEmotion("neutral")
        animatronic.setHeadRotation(0, 0)
        animatronic.setArmPosition("left", 0)
        animatronic.setArmPosition("right", 0)
        print("애니메트로닉 리셋 완료")
    end
end

3. 레드스톤 신호 지연

-- 해결 방법: 신호 동기화
local function synchronizeRedstoneSignals(devices)
    for _, device in ipairs(devices) do
        local router = peripheral.find("cccbridge:red_router")
        if router then
            router.transmit(device.channel, device.name, device.state)
            sleep(0.1) -- 짧은 지연으로 동기화
        end
    end
end

확장 및 커스터마이징

1. 커스텀 API 개발

-- CC:C Bridge 확장 API
local CCCBridgeAPI = {}

function CCCBridgeAPI.getAllPeripherals()
    local peripherals = {
        sources = {},
        targets = {},
        animatronics = {},
        redRouters = {}
    }
    
    local names = peripheral.getNames()
    for _, name in ipairs(names) do
        local type = peripheral.getType(name)
        local device = peripheral.wrap(name)
        
        if type == "cccbridge:source" then
            table.insert(peripherals.sources, device)
        elseif type == "cccbridge:target" then
            table.insert(peripherals.targets, device)
        elseif type == "cccbridge:animatronic" then
            table.insert(peripherals.animatronics, device)
        elseif type == "cccbridge:red_router" then
            table.insert(peripherals.redRouters, device)
        end
    end
    
    return peripherals
end

function CCCBridgeAPI.broadcastToAllTargets(message)
    local peripherals = CCCBridgeAPI.getAllPeripherals()
    
    for _, target in ipairs(peripherals.targets) do
        target.setSignText("broadcast", {"방송", message, "", os.date("%H:%M")})
    end
end

function CCCBridgeAPI.animateAllRobots(emotion)
    local peripherals = CCCBridgeAPI.getAllPeripherals()
    
    for _, animatronic in ipairs(peripherals.animatronics) do
        animatronic.setEmotion(emotion)
    end
end

return CCCBridgeAPI

2. 플러그인 시스템

-- 플러그인 매니저
local PluginManager = {}
PluginManager.__index = PluginManager

function PluginManager.new()
    local self = setmetatable({}, PluginManager)
    self.plugins = {}
    self.hooks = {}
    return self
end

function PluginManager:loadPlugin(name, plugin)
    self.plugins[name] = plugin
    
    if plugin.initialize then
        plugin.initialize()
    end
    
    print("플러그인 로드됨: " .. name)
end

function PluginManager:registerHook(event, callback)
    if not self.hooks[event] then
        self.hooks[event] = {}
    end
    table.insert(self.hooks[event], callback)
end

function PluginManager:executeHooks(event, ...)
    if self.hooks[event] then
        for _, callback in ipairs(self.hooks[event]) do
            callback(...)
        end
    end
end

-- 예시 플러그인: 자동 백업
local AutoBackupPlugin = {
    name = "AutoBackup",
    version = "1.0"
}

function AutoBackupPlugin.initialize()
    print("자동 백업 플러그인 초기화")
end

function AutoBackupPlugin.backup()
    print("시스템 백업 실행 중...")
    -- 백업 로직 구현
end

-- 플러그인 사용
local manager = PluginManager.new()
manager:loadPlugin("AutoBackup", AutoBackupPlugin)
manager:registerHook("hourly", AutoBackupPlugin.backup)

결론

CC:C Bridge는 마인크래프트에서 ComputerCraft와 Create 모드를 완벽하게 통합하여 전례 없는 자동화 경험을 제공합니다. Source Block과 Target Block을 통한 정밀한 기계 제어, 애니메트로닉을 활용한 인터랙티브 로봇 시스템, RedRouter를 통한 복잡한 레드스톤 네트워크까지, 이 모드는 마인크래프트 자동화의 새로운 차원을 열어줍니다.

핵심 장점 요약

  1. 완벽한 통합: ComputerCraft와 Create의 장점을 모두 활용
  2. 정밀한 제어: Lua 스크립트를 통한 세밀한 기계 관리
  3. 확장성: 모듈식 설계로 무한한 확장 가능
  4. 사용자 친화적: 직관적인 API와 풍부한 예제
  5. 안정성: 강력한 에러 처리와 복구 메커니즘

다음 단계

  1. 고급 프로젝트: 대규모 팩토리 자동화 시스템 구축
  2. 멀티플레이어: 서버 환경에서의 협업 자동화
  3. AI 통합: 머신러닝을 활용한 지능형 자동화
  4. 커뮤니티: 다른 플레이어들과 스크립트 및 설계 공유

CC:C Bridge를 통해 마인크래프트에서 꿈꿔왔던 완벽한 자동화 세계를 실현하고, 창의적인 엔지니어링의 즐거움을 만끽하세요.

추가 리소스