CC SmartCard

适用于 CC: Tweaked 的可编程智能卡、身份扫描仪、通行传感器和门禁闸机。
与持有者可以自由读写其共享存储的 CC 磁盘不同,智能卡在发行时仅写入一次。此后无法直接读取其内容或随意更改;它只能运行发行时定义的命令,从而提供不同的安全边界和使用模型。
它旨在用于 ComputerCraft 风格的访问卡、身份验证、票据、令牌、银行系统以及其他需要超越普通物品 ID 功能的建筑。
智能卡

- 为每张卡片设置公共 ID 和可选标签。
- 染色卡片而不改变其身份、程序或存储的文件。
- 从单个 Lua 源字符串或文件目录发行卡片。
- 使已发行的程序及其存储对普通阅读器 API 保持私有。
- 独立于调用计算机运行卡片程序。
通过支持的阅读器 API,已发行的卡片无法被擦除或重新发行。
智能卡阅读器
将阅读器放置在 CC: Tweaked 电脑旁边,或通过有线调制解调器连接。右键点击阅读器的任意一面以插入或移除卡片。
smart_card_reader 外围设备可以检查卡片的公共元数据、发行空白卡片、在已发行的卡片上调用命令,并生成插入或移除事件。
local reader = peripheral.find("smart_card_reader")
assert(reader, "未找到智能卡阅读器")
local message, cardId = reader.call("ping")
print(message, cardId)
指纹扫描仪

fingerprint_scanner 外围设备等待玩家右键点击扫描仪,短暂点亮其扫描面,并返回玩家的稳定 UUID 及其当前配置文件名称。
local scanner = peripheral.find("fingerprint_scanner")
local player = assert(scanner.scan())
print(player.name, player.uuid)
门禁闸机和通行传感器

构建自动化边境控制车道、安全门厅、车站屏障或其他任何两阶段通行设施。演示使用了两个独立的门禁闸机和一个通行传感器:入口初始处于开启状态,一名玩家进入后关闭,内部计算机授权出口,玩家离开后车道重置。
放置两个面对面且间隔为一到两个方块的柜体,形成一个动画式的 access_gate 外围设备。两个柜体控制同一个逻辑闸机。
- 玻璃会在 10 个游戏刻内异步地打开或关闭。
- 受阻时会自动反转并重新打开。
- 柜体灯光显示红色表示关闭,琥珀色表示移动或故障,绿色表示开启。
- 闸机忽略红石信号,且无法通过直接的玩家交互移动。
- 当最后附加的计算机断开连接时,闸机会等待一秒钟然后强制开启。
- 闸机状态变化和遮挡情况可作为 ComputerCraft 事件获取。
两个闸机保持独立:你的 Lua 程序决定认证方式以及是否只允许一个闸机开启。这使得这些方块不仅仅局限于单一的硬编码边境控制工作流程。
在受控空间上方安装 passage_sensor 以接收关于玩家、生物、载具、物品和其他实体的匿名观测数据。其检测立方体可通过 Lua 配置,范围最大为距离传感器 8 个方块内的 256 个方块。程序可以使用 getEntities() 查询快照,或对进入、退出和重置事件做出反应。Lua 决定什么算作旅行者;传感器永远不会暴露玩家的 UUID、名称、装备、背包或 NBT 数据。
卡片工作原理
- 制作智能卡和智能卡阅读器。
- 将阅读器连接到 CC: Tweaked 电脑。
- 插入空白卡片并一次性发行其 Lua 程序。
- 将已发行的卡片插入其他阅读器,并调用诸如
authorize(授权)、validate(验证)、claim(认领)或 redeem(兑换)等命令。
卡片程序拥有自己的文件存储,并可使用熟悉的 ComputerCraft API。对于需要随机数或秘密材料的程序,卡片运行时环境中也提供了安全的随机字节。
建筑创意
- 银行卡和商店终端
- 房间钥匙和访问徽章
- 火车票和活动通行证
- 包裹取件令牌
- 会员卡和优惠券
- 结合智能卡与实时指纹扫描的双重认证系统
- 自动化边境控制车道和双闸机互锁通道
- 监狱、银行、仓库和车站的门禁闸机
合成配方

图片涵盖了原始卡片和身份方块。柜体和通行传感器的配方包含在下方的文本参考中。
文本配方参考
智能卡
无形状合成:纸张、红石粉、铜锭和可选染料。
智能卡阅读器
###
#R#
#C#
指纹扫描仪
SCS
RGR
SCS
S = 石头
C = 铜锭
R = 红石粉
G = 玻璃板
柜体(产出 2 个)
SGS
PRP
SCS
S = 石头
G = 玻璃板
P = 活塞
R = 红石粉
C = 铜锭
通行传感器
CGC
ROR
SSS
S = 石头
C = 铜锭
G = 玻璃板
R = 红石粉
O = 侦测器
要求
- Minecraft 1.21.1
- NeoForge 21.1.235 或更高版本(21.1 系列)
- CC: Tweaked 1.120.0 或更高版本
- Java 21
在服务器上安装 CC SmartCard。多人游戏客户端也应安装该模组,以便其方块、物品、模型和翻译内容可用。
文档
完整 README 和 API 参考 涵盖了卡片的签发、读取器事件、所有外围设备方法、卡片运行时 API、文件布局以及完整示例。
源代码 · 问题追踪器
卡片隐私是一种玩法边界,而非针对服务器管理员或其他游戏外访问的正式保护措施。
CC SmartCard

Programmable Smart Cards, identity scanners, passage sensors, and access gates for CC: Tweaked.
Unlike a CC disk, whose holder can freely read and write its shared storage, a Smart Card is written only once when issued. Its contents cannot then be read directly or arbitrarily changed; it can only run commands defined at issuance, giving it a different security boundary and usage model.
It is designed for ComputerCraft-style access cards, identity checks, tickets, tokens, banking systems, and other builds that need more than a plain item ID.
Smart Cards

- Give each card a public ID and optional label.
- Dye cards without changing their identity, program, or stored files.
- Issue a card from one Lua source string or a directory of files.
- Keep the issued program and its storage private from the normal reader API.
- Run card programs independently from the calling computer.
Issued cards cannot be erased or reissued through the supported reader API.
Smart Card Reader
Place the reader beside a CC: Tweaked computer or connect it through a wired modem. Insert or remove a card by right-clicking any face of the reader.
The smart_card_reader peripheral can inspect public card metadata, issue a blank card, call commands on an issued card, and emit insertion or removal events.
local reader = peripheral.find("smart_card_reader")
assert(reader, "No Smart Card Reader found")
local message, cardId = reader.call("ping")
print(message, cardId)
Fingerprint Scanner

The fingerprint_scanner peripheral waits for a player to right-click the scanner, briefly lights its scanned face, and returns the player's stable UUID together with their current profile name.
local scanner = peripheral.find("fingerprint_scanner")
local player = assert(scanner.scan())
print(player.name, player.uuid)
Access Gates and Passage Sensors

Build automated border-control lanes, secure vestibules, station barriers, or any other two-stage passage. The demonstration uses two independent Access Gates and one Passage Sensor: the entrance starts open, closes after one player enters, the inside computer authorises the exit, and the lane resets after the player leaves.
Place two Gate Cabinets facing each other across a one- or two-block gap to form one animated access_gate peripheral. Both cabinets control the same logical gate.
- Glass leaves open or close asynchronously over 10 game ticks.
- Obstructed leaves automatically reverse and reopen.
- Cabinet lights show red for closed, amber for movement or faults, and green for open.
- Gates ignore redstone and cannot be moved by direct player interaction.
- When the final attached computer disconnects, the gate waits one second and fails open.
- Gate state changes and obstructions are available as ComputerCraft events.
Two gates remain independent: your Lua program decides how authentication works and whether only one gate may be open. This makes the blocks useful beyond a single hard-coded border-control workflow.
Mount a passage_sensor above the controlled space to receive anonymous observations for players, creatures, vehicles, items, and other entities. Its detection cuboid is configurable from Lua, up to 256 blocks within eight blocks of the sensor. Programs can query a snapshot with getEntities() or react to entry, exit, and reset events. Lua chooses what counts as a traveller; the sensor never exposes player UUIDs, names, equipment, inventories, or NBT.
How Cards Work
- Craft a Smart Card and Smart Card Reader.
- Connect the reader to a CC: Tweaked computer.
- Insert a blank card and issue its Lua program once.
- Insert the issued card into other readers and call commands such as
authorize, validate, claim, or redeem.
Card programs receive their own file storage and may use familiar ComputerCraft APIs. Secure random bytes are also available inside the card runtime for programs that need nonces or secret material.
Build Ideas
- Bank cards and shop terminals
- Room keys and access badges
- Train tickets and event passes
- Parcel pickup tokens
- Loyalty and coupon cards
- Two-factor systems combining a Smart Card with a live fingerprint scan
- Automated border-control lanes and two-gate interlocked passages
- Prison, bank, warehouse, and station access gates
Crafting

The image covers the original card and identity blocks. Gate Cabinet and Passage Sensor recipes are included in the text reference below.
Text recipe reference
Smart Card
Shapeless: Paper, Redstone Dust, Copper Ingot, and optional dyes.
Smart Card Reader
###
#R#
#C#
# = Stone
R = Redstone Dust
C = Copper Ingot
Fingerprint Scanner
SCS
RGR
SCS
S = Stone
C = Copper Ingot
R = Redstone Dust
G = Glass Pane
Gate Cabinets (makes 2)
SGS
PRP
SCS
S = Stone
G = Glass Pane
P = Piston
R = Redstone Dust
C = Copper Ingot
Passage Sensor
CGC
ROR
SSS
S = Stone
C = Copper Ingot
G = Glass Pane
R = Redstone Dust
O = Observer
Requirements
- Minecraft 1.21.1
- NeoForge 21.1.235 or newer in the 21.1 line
- CC: Tweaked 1.120.0 or newer
- Java 21
Install CC SmartCard on the server. Multiplayer clients should also install it so its blocks, items, models, and translations are available.
Documentation
The full README and API reference covers issuing, reader events, every peripheral method, the card runtime API, file layout, and complete examples.
Source code · Issue tracker
Card privacy is a gameplay boundary, not formal protection against server administrators or other out-of-game access.
评论 0
登录后参与评分
还没有评论,来抢沙发吧