Create: Radionautics 旨在成为一款模组,允许使用逼真的无线电在玩家和计算机之间进行通信。目前,黄铜无线电链路旨在为红石链路提供无限范围(其加密模式尚不可用)。
CC:Tweaked 的天线旨在替换调制解调器,增加计算机连接强度的进度;目前只有黄铜天线可以连接沙质实体与其他沙质实体或普通世界,因为它们拥有无限范围。
花岗岩天线的范围为 2000 格,铜天线的范围为 500 格。
关于如何通过天线进行 UDP 或 TCP 传输的简单教程
Create: Radionautics CC:Tweaked 指南
Create: Radionautics 为 CC:Tweaked 计算机添加了无线电外围设备。这些无线电允许计算机通过 Create 主题的天线方块发送长距离消息。
要求
- Minecraft 1.21.1
- NeoForge
- Create
- Create Aeronautics
- CC:Tweaked
- Create: Radionautics
无线电方块
Radionautics 添加了三种 CC:Tweaked 无线电天线外围设备:
| 方块 |
范围 |
活动绑定频率数 |
| 花岗岩无线电天线 |
2000 格 |
1 |
| 铜无线电天线 |
5000 格 |
2 |
| 黄铜无线电天线 |
无限 |
5 |
将无线电天线直接放置在 CC:Tweaked 计算机旁边。
获取外围设备
使用 peripheral.find:
local radio = peripheral.find("radionautics_radio")
或者包装已知的侧面:
local radio = peripheral.wrap("left")
你可以检查无线电层级:
print(radio.tier())
print(radio.range())
print(radio.maxBinds())
发送消息
发送方:
local radio = peripheral.find("radionautics_radio")
radio.send("145.500", "chat:hello from base")
第一个参数是频率。第二个参数是消息。
接收消息
接收方:
local radio = peripheral.find("radionautics_radio")
radio.udpBind("145.500")
while true do
local event, frequency, senderId, message = os.pullEvent("radio_message")
print("Frequency: " .. frequency)
print("Sender: " .. senderId)
print("Message: " .. message)
end
接收方必须先绑定频率:
radio.udpBind("145.500")
传入的消息会触发 radio_message 事件:
local event, frequency, senderId, message = os.pullEvent("radio_message")
聊天示例
在接收计算机上运行此代码:
local radio = peripheral.find("radionautics_radio")
radio.udpBind("145.500")
print("Listening on 145.500")
while true do
local event, frequency, senderId, message = os.pullEvent("radio_message")
print("[" .. frequency .. "] " .. senderId .. ": " .. message)
end
在发送计算机上运行此代码:
local radio = peripheral.find("radionautics_radio")
while true do
write("Message: ")
local message = read()
radio.send("145.500", "chat:" .. message)
end
加密辅助工具
Radionautics 包含用于编码/加密的辅助方法。
可用的加密类型:
加密发送方:
local radio = peripheral.find("radionautics_radio")
local key = "secret-key"
local message = "chat:encrypted hello"
local encrypted = radio.cryptoEncrypt("aes", message, key)
radio.send("145.500", encrypted)
加密接收方:
local radio = peripheral.find("radionautics_radio")
radio.udpBind("145.500")
local key = "secret-key"
while true do
local event, frequency, senderId, encrypted = os.pullEvent("radio_message")
local ok, message = pcall(function()
return radio.cryptoDecrypt("aes", encrypted, key)
end)
if ok then
print(message)
end
end
如果使用错误的密钥,解密可能会失败。如果你希望安全地忽略错误数据包,请使用 pcall。
频率
频率是文本。它们可以是数字或名称:
radio.udpBind("145.500")
radio.udpBind("AIRSHIP")
radio.udpBind("main_base")
发送方和接收方必须使用相同的频率。
绑定限制
每个天线层级都有最大活动绑定频率数。
radio.udpBind("145.500")
radio.udpBind("fleet")
如果天线没有剩余的绑定槽位,绑定将返回 false。
完成后关闭频率:
radio.close("145.500")
列出活动的绑定:
for _, frequency in ipairs(radio.boundFrequencies()) do
print(frequency)
end
队列消息
你可以手动轮询消息:
local packet = { radio.receive() }
if packet[1] then
local frequency = packet[1]
local senderId = packet[2]
local message = packet[3]
print(message)
end
通常,os.pullEvent("radio_message") 更容易使用。
检查队列消息数量:
print(radio.queuedMessages())
Sable / 飞船辅助工具
Radionautics 暴露了早期的 Sable/Create Aeronautics 辅助方法:
radio.sableContinousLoad(true)
radio.sableContinousLoad(false)
检查是否启用了连续加载:
print(radio.sableIsContinousLoading())
获取当前飞船中心位置:
local pos = radio.sableShipCenterPos()
print(pos.x, pos.y, pos.z)
注意:飞船集成仍在开发中。当前行为可能会回退到方块位置。
可选辅助 API
Radionautics 还提供了辅助 API:
local radio = radionautics.find()
radio.udpBind("145.500")
radio.send("145.500", "chat:hello")
加密辅助:
local encrypted = radionautics.crypto.encrypt("aes", "hello", "key")
local clear = radionautics.crypto.decrypt("aes", encrypted, "key")
Sable 辅助:
radionautics.sable.continousLoad(true)
故障排除
No radionautics_radio peripheral attached
确保天线方块直接位于计算机旁边。
未收到消息
检查:
- 接收器调用了
radio.udpBind(frequency)。
- 发送方和接收方使用完全相同的频率。
- 天线位于同一个维度中。
- 天线之间的距离在有效范围内。
- 接收器的程序仍在运行。
加密消息失败
请检查:
- 两台计算机使用了相同的加密类型。
- 两台计算机使用了相同的密钥。
- 如果接收器希望忽略无效数据包,则应使用
pcall。
绑定失败
天线可能已超出活跃频率槽位数量限制。
请使用以下命令查看当前状态:
print(radio.maxBinds())
print(radio.boundFrequencies())
然后关闭不再使用的频率槽:
radio.close("old_frequency")
Create Radionautics is ment to be a mod where realistic radios can be used to comunicate between players and computers. Currently There is a brass radio link ment to add infinite range for redstone links (its encryption mode doesn't work yet).
The anntennas for cc:tweaked are ment to replace modems adding a progrssion to how strong connections can be for computers currenlty only brass anntenna can connect sable entities to other sable entities or the normal world as they have infinite range.
The andesite anntenna has a range of 2000 blocks and the copper anntenna has a range of 500 blocks
A simple tutorial on how to use the anntenas for UDP or TCP transfers via anntenas
Create: Radionautics CC:Tweaked Guide
Create: Radionautics adds radio peripherals for CC:Tweaked computers. These radios let computers send messages over long distances using Create-themed antenna blocks.
Requirements
- Minecraft 1.21.1
- NeoForge
- Create
- Create Aeronautics
- CC:Tweaked
- Create: Radionautics
Radio Blocks
Radionautics adds three CC:Tweaked radio antenna peripherals:
| Block |
Range |
Active bound frequencies |
| Andesite Radio Antenna |
2000 blocks |
1 |
| Copper Radio Antenna |
5000 blocks |
2 |
| Brass Radio Antenna |
Infinite |
5 |
Place a radio antenna directly next to a CC:Tweaked computer.
Getting The Peripheral
Use peripheral.find:
local radio = peripheral.find("radionautics_radio")
Or wrap a known side:
local radio = peripheral.wrap("left")
You can check the radio tier:
print(radio.tier())
print(radio.range())
print(radio.maxBinds())
Sending A Message
Sender:
local radio = peripheral.find("radionautics_radio")
radio.send("145.500", "chat:hello from base")
The first argument is the frequency. The second argument is the message.
Receiving Messages
Receiver:
local radio = peripheral.find("radionautics_radio")
radio.udpBind("145.500")
while true do
local event, frequency, senderId, message = os.pullEvent("radio_message")
print("Frequency: " .. frequency)
print("Sender: " .. senderId)
print("Message: " .. message)
end
The receiver must bind the frequency first:
radio.udpBind("145.500")
Incoming messages fire a radio_message event:
local event, frequency, senderId, message = os.pullEvent("radio_message")
Chat Example
Run this on the receiving computer:
local radio = peripheral.find("radionautics_radio")
radio.udpBind("145.500")
print("Listening on 145.500")
while true do
local event, frequency, senderId, message = os.pullEvent("radio_message")
print("[" .. frequency .. "] " .. senderId .. ": " .. message)
end
Run this on the sending computer:
local radio = peripheral.find("radionautics_radio")
while true do
write("Message: ")
local message = read()
radio.send("145.500", "chat:" .. message)
end
Encryption Helpers
Radionautics includes helper methods for encoding/encryption.
Available crypto types:
Encrypted sender:
local radio = peripheral.find("radionautics_radio")
local key = "secret-key"
local message = "chat:encrypted hello"
local encrypted = radio.cryptoEncrypt("aes", message, key)
radio.send("145.500", encrypted)
Encrypted receiver:
local radio = peripheral.find("radionautics_radio")
radio.udpBind("145.500")
local key = "secret-key"
while true do
local event, frequency, senderId, encrypted = os.pullEvent("radio_message")
local ok, message = pcall(function()
return radio.cryptoDecrypt("aes", encrypted, key)
end)
if ok then
print(message)
end
end
If the wrong key is used, decrypting may fail. Use pcall if you want to ignore bad packets safely.
Frequencies
Frequencies are text. They can be numbers or names:
radio.udpBind("145.500")
radio.udpBind("AIRSHIP")
radio.udpBind("main_base")
The sender and receiver must use the same frequency.
Bind Limits
Each antenna tier has a maximum number of active bound frequencies.
radio.udpBind("145.500")
radio.udpBind("fleet")
If the antenna is out of bind slots, binding returns false.
Close a frequency when finished:
radio.close("145.500")
List active binds:
for _, frequency in ipairs(radio.boundFrequencies()) do
print(frequency)
end
Queued Messages
You can poll messages manually:
local packet = { radio.receive() }
if packet[1] then
local frequency = packet[1]
local senderId = packet[2]
local message = packet[3]
print(message)
end
Usually, os.pullEvent("radio_message") is easier.
Check queued message count:
print(radio.queuedMessages())
Sable / Ship Helpers
Radionautics exposes early Sable/Create Aeronautics helper methods:
radio.sableContinousLoad(true)
radio.sableContinousLoad(false)
Check if continuous loading is enabled:
print(radio.sableIsContinousLoading())
Get the current ship center position:
local pos = radio.sableShipCenterPos()
print(pos.x, pos.y, pos.z)
Note: ship integration is still being developed. Current behavior may fall back to block position.
Optional Helper API
Radionautics also provides a helper API:
local radio = radionautics.find()
radio.udpBind("145.500")
radio.send("145.500", "chat:hello")
Crypto helper:
local encrypted = radionautics.crypto.encrypt("aes", "hello", "key")
local clear = radionautics.crypto.decrypt("aes", encrypted, "key")
Sable helper:
radionautics.sable.continousLoad(true)
Troubleshooting
No radionautics_radio peripheral attached
Make sure the antenna block is directly next to the computer.
No message received
Check:
- Receiver called
radio.udpBind(frequency).
- Sender and receiver use the exact same frequency.
- The antennas are in the same dimension.
- The antennas are within range.
- The receiver program is still running.
Encrypted message fails
Check:
- Both computers use the same crypto type.
- Both computers use the same key.
- The receiver uses
pcall if it wants to ignore bad packets.
Bind fails
The antenna may be out of active frequency slots.
Use:
print(radio.maxBinds())
print(radio.boundFrequencies())
Then close unused frequencies:
radio.close("old_frequency")
评论 0
登录后参与评分
还没有评论,来抢沙发吧