MCAPIBridge
MCAPIBridge 是一款功能强大的 Fabric 模组,用于 Minecraft,它在游戏与外部脚本(如 Python)之间建立了实时的 TCP 套接字连接。它提供了一个全面的 API,允许通过编程方式控制世界、实体和玩家状态,充当 Minecraft 的可编程接口。
灵感源自经典的 Minecraft Pi Protocol (MCPI) 和 RaspberryJuice 插件。
⚡ 核心功能
? 套接字服务器
- 端口 4711:开启本地 TCP 服务器,监听基于文本的命令。
- 协议:稳健的基于行的协议,兼容任何编程语言。
- 多客户端:支持通过多线程同时连接多个脚本。
? 世界与维度控制
- 方块操作:即时放置或查询任意方块(支持模组添加的方块)。
- 维度支持:命令可自动针对特定维度(主世界、下界、末地)执行。
- 告示牌编辑:动态修改告示牌上的文本。
- 服务器命令:以 OP(管理员)权限执行任何原版服务器命令(例如
/time、/weather)。
? 实体与物理引擎
- 高级生成:使用精确坐标和**旋转角度(偏航角/俯仰角)**召唤实体。
- 物理控制:
- 速度:对实体应用力矢量以将其发射出去(创建投射物)。
- 重力:为特定实体开关重力(例如,创建直线飞行的箭矢)。
- 实体雷达:扫描并检索指定半径内的所有实体列表。
- 粒子系统:生成具有自定义数量、速度和扩散体积的视觉效果。
- 强制注视:控制玩家或实体的注视方向,非常适合电影镜头或恐怖机制。
? 玩家管理
- 属性控制:读取和修改生命值(可突破原版限制)、饥饿值和游戏模式。
- 能力设置:切换飞行(即使在生存模式下)、上帝模式(无敌),并调整移动速度(行走/飞行)。
- 物品栏 API:
- 读取:获取完整的物品栏内容(主手、护甲、副手)。
- 写入:给予物品或清除特定物品/槽位。
- 详细信息:访问实时数据,包括精确的位置、旋转角度和手持物品。
- 传送:跨坐标和维度传送玩家或实体。
?️ 输入与事件系统
- 双向架构:包含客户端和服务端逻辑,以实现精确的输入检测。
- 射线检测交互:
- 右键点击:检测高达500 格远的交互(服务端射线检测)。
- 左键点击:检测交互和攻击行为。
- 聊天监听器:将游戏内聊天消息实时流式传输到外部脚本。
- 宏按键:在游戏控制菜单中注册5 个自定义宏按键。脚本可以监听这些特定的按键按下以触发自定义逻辑。
? 自定义音频系统
- 音调生成:生成具有自定义频率、持续时间和采样率的正弦波音调。
- WAV 文件播放:加载并播放自定义 WAV 音频文件(8/16 位 PCM,单声道/立体声)。
- 3D 空间音频:在世界特定坐标处播放声音,并具有真实的距离衰减效果。
- 动态控制:实时音量调节、循环播放、暂停/停止以及移动声源的位置更新。
- 多源混音:同时播放多个音频源(例如,和弦、环境层)。
- 音频克隆:高效克隆已加载的音频数据,以实现低延迟的多扬声器设置。
?️ 自定义屏幕系统
- 动态网页屏幕:新增自定义方块
mcapibridge:screen,可由脚本控制显示实时图像或视频流。 - 无缝拼接:自动将相邻的屏幕方块合并为一个大型显示屏,非常适合视频墙或广告牌。
- 高性能:使用客户端纹理渲染和 JPG/PNG 流媒体实现流畅的 30 FPS 播放。推荐使用 JPG 流媒体。
- 交互式配置:右键单击屏幕方块即可轻松配置 ID 和布局,无需使用命令。
- 合成配方:
G G G (玻璃板) R D R (红石, 闪烁的红石粉, 红石) I I I (铁锭)
⚡ 物理 IO 系统
- IO 端口方块:专用方块
mcapibridge:io,将 Minecraft 红石与外部硬件/脚本桥接起来。 - 输入模式:脚本发送信号 -> 方块输出红石能量(0-15)。
- 输出模式:方块检测红石能量 -> 向脚本发送事件。
- 实时交互:非常适合从 Minecraft 控制智能家居设备或在游戏内可视化传感器数据。
- 合成配方:
I R I (铁锭, 红石, 铁锭) S S S (石头)
? 深度数据访问 (NBT)
- NBT 修改:直接向实体和方块实体写入原始 NBT 数据。
- 高级定制:使用类 JSON 的 NBT 字符串创建巨人、冻结怪物(
NoAI)、使实体发光,或用自定义战利品填满箱子。
安装
Modrinth
⚠️ 安全警告
此模组会开启端口 4711,并授予连接到该端口的任何程序完全的管理员 (OP) 权限。
- 切勿在没有防火墙的情况下将此模组安装在公共服务器上。
- 它仅设计用于单人游戏、局域网或私有服务器。
桥梁库
Python 库
Python 示例
C# 库
C# 示例
Dart 库
Dart 示例
未来将支持更多语言。
? 更新日志
2026年2月24日
- 添加 Dart 支持
2026年2月13日
- 添加对 1.21.4、1.20.4、1.20.1 的支持。
- 修复音频错误。现在你可以使用
audio.play来恢复暂停的音频。
2026年2月11日
- C#:添加了 C# 支持。
- 1.21.1:添加了对 1.21.1 的支持。
2026年2月10日 Alpha-0.5.1
- IO 区块更新:添加了
mc.io.config方法,允许通过脚本动态重新配置 IO 区块。
2026年2月9日 Alpha-0.5.0
- 物理 IO 系统:添加了
mcapibridge:io区块,用于桥接红石与外部 IO。- 输入模式:通过脚本控制游戏内的红石信号强度。
- 输出模式:在脚本中监控游戏内红石信号的变化。
- 交互式配置:右键点击以打开 GUI 设置通道 ID 和模式。
- 视觉反馈:区块纹理根据模式(输入/输出)发生变化。
2026年2月8日 Alpha-0.4.1
- 音频与视频维度支持:实现了基于维度的播放功能。屏幕和 3D 音频现在可以在主世界、下界和末地之间正确隔离。
- 热加入与恢复播放:添加了状态持久化和偏移量同步。新加入服务器的玩家将自动接收音频数据,并与视频完美同步恢复播放。
- 同步调整:在音频设置中添加了一个滑块,用于手动调整音频延迟补偿(+/- 5.00秒)。
2026年2月6日 Alpha-0.4.0
- 自定义屏幕系统:引入了
mcapibridge:screen区块,用于显示实时图像和视频流。- 视频墙:支持无缝的多区块屏幕组装,并具备自动布局检测功能。
- 高分辨率流媒体:能够通过 JPG/PNG 压缩以 30 FPS 的帧率流式传输 1080p/720p 内容。
- 简易配置:右键点击以打开 GUI 设置屏幕 ID。
- 音频优化:添加了
audio.clone命令,能够高效复制音频源以供多扬声器设置(如环绕声影院)使用,而无需重新上传数据。 - 已修复的错误:
- 修复了
play3d音频无法自动将音量设置为 0 的问题。 - 修复了套接字有时仍会与桥接保持连接的问题。
- 修复了
2026年2月4日 Alpha-0.3.1
- 音频设置集成:在 Minecraft 的声音选项菜单中添加了原生的 "MCAPIBridge Audio" 音量滑块。
2026年2月4日 Alpha-0.3.0
- 自定义音频系统:通过 OpenAL 添加了完整的音频播放功能。
- 音调生成:创建具有可配置频率和持续时间的正弦波音调。
- WAV 支持:加载并播放自定义
.wav文件(自动将立体声转换为单声道)。 - 3D 空间音频:在世界坐标处播放音频,并具有真实的距离衰减和回滚控制。
- 动态位置:实时更新声源位置以实现环绕效果。
- 播放控制:提供音量调节、循环切换、暂停、停止和卸载功能。
- 多声源:同时播放多个音频源,以生成和弦和分层音频。
2026年2月1日 Alpha-0.2.2
- 深度数据控制:添加了实体和方块的 NBT 修改 支持,允许进行高级定制,例如巨型生物或自定义战利品。
- 摄像机控制:实现了
lookAtAPI,强制玩家或实体看向特定坐标。
2026年1月31日 Alpha-0.2.1
- 已修复错误:单个点击或聊天事件现在可以由多个连接的脚本处理。
2026年1月31日 Alpha-0.2.0
- 客户端输入:即使瞄准空气也能检测到左键/右键点击(使用客户端数据包)。
- 宏按键:在游戏设置中添加了 5 个可自定义的按键,脚本可以监听这些按键以触发自定义操作。
?️ 路线图
- 更多语言桥接:用于 ESP32 的 Arduino 和 Micropython 库。
MCAPIBridge
MCAPIBridge is a powerful Fabric mod for Minecraft that establishes a real-time TCP socket connection between the game and external scripts (Python, etc.). It exposes a comprehensive API allowing programmatic control over the world, entities, and player states, acting as a programmable interface for Minecraft.
Inspired by the classic Minecraft Pi Protocol (MCPI) and the RaspberryJuice plugin.
⚡ Core Capabilities
? Socket Server
- Port 4711: Opens a local TCP server listening for text-based commands.
- Protocol: Robust line-based protocol compatible with any programming language.
- Multi-Client: Supports multiple concurrent script connections via multithreading.
? World & Dimension Control
- Block Manipulation: Place or query any block (supports modded blocks) instantly.
- Dimension Support: Commands can target specific dimensions (Overworld, Nether, The End) automatically.
- Sign Editing: Modify text on sign blocks dynamically.
- Server Commands: Execute any vanilla server command (e.g.,
/time,/weather) with OP privileges.
? Entity & Physics Engine
- Advanced Spawning: Summon entities with precise coordinates and rotation (Yaw/Pitch).
- Physics Control:
- Velocity: Apply force vectors to entities to launch them (creating projectiles).
- Gravity: Toggle gravity on/off for specific entities (e.g., creating laser-straight arrows).
- Entity Radar: Scan and retrieve a list of all entities within a specified radius.
- Particle System: Generate visual effects with custom count, speed, and diffusion volume.
- Forced Look: Control where a player or entity is looking with lookAt, perfect for cinematics or horror mechanics.
? Player Management
- Stats Control: Read and modify Health (can break vanilla limits), Food Level, and Game Mode.
- Abilities: Toggle Flight (even in Survival mode), God Mode (Invulnerability), and adjust Movement Speeds (Walk/Fly).
- Inventory API:
- Read: Retrieve full inventory contents (Main, Armor, Offhand).
- Write: Give items or Clear specific items/slots.
- Detailed Info: Access real-time data including exact position, rotation, and held items.
- Teleportation: Teleport players or entities across coordinates and dimensions.
?️ Input & Events System
- Dual-Sided Architecture: Includes both Client and Server logic for precise input detection.
- Raycasting Interactions:
- Right Click: Detects interaction up to 500 blocks away (Server-side raycasting).
- Left Click: Detects interactions and attacks.
- Chat Listener: Streams in-game chat messages to the external script in real-time.
- Macro Keys: Registers 5 Custom Macro Keys in the game's controls menu. Scripts can listen for these specific key presses to trigger custom logic.
? Custom Audio System
- Tone Generation: Generate sine wave tones with custom frequency, duration, and sample rate.
- WAV File Playback: Load and play custom WAV audio files (8/16-bit PCM, Mono/Stereo).
- 3D Spatial Audio: Play sounds at specific world coordinates with realistic distance attenuation.
- Dynamic Controls: Real-time volume adjustment, loop playback, pause/stop, and position updates for moving sound sources.
- Multi-Source Mixing: Play multiple audio sources simultaneously (e.g., chords, ambient layers).
- Audio Cloning: Efficiently clone loaded audio data for low-latency multi-speaker setups.
?️ Custom Screen System
- Dynamic Web Screen: A new custom block
mcapibridge:screenthat can display real-time images or video streams controlled by scripts. - Seamless Tiling: Automatically merges adjacent screen blocks into a single large display, perfect for video walls or billboards.
- High Performance: Uses client-side texture rendering and JPG/PNG streaming for smooth 30 FPS playback. Recommend JPG streaming.
- Interactive Configuration: Right-click screen blocks to easily configure IDs and layout without commands.
- Crafting Recipe:
G G G (Glass Pane) R D R (Redstone, Glowstone Dust, Redstone) I I I (Iron Ingot)
⚡ Physical IO System
- IO Port Block: A specialized block
mcapibridge:iothat bridges Minecraft Redstone with external hardware/scripts. - Input Mode: Scripts sends signals -> Block emits Redstone power (0-15).
- Output Mode: Block detects Redstone power -> Sends events to scripts.
- Real-time Interaction: Perfect for controlling smart home devices from Minecraft or visualizing sensor data in-game.
- Crafting Recipe:
I R I (Iron Ingot, Redstone, Iron Ingot) S S S (Stone)
? Deep Data Access (NBT)
- NBT Modification: Directly write raw NBT data to Entities and Block Entities.
- Advanced Customization: Create giants, freeze mobs (
NoAI), make entities glow, or fill chests with custom loot using JSON-like NBT strings.
Install
Modrinth
⚠️ Security Warning
This mod opens Port 4711 and grants Full Administrative (OP) Permissions to any program that connects to it.
- Do not install this on a public server without a firewall.
- It is designed for single-player, LAN, or private server use only.
Bridges
Python Library
Python Examples
C# Library
C# Examples
Dart Library
Dart Examples
More languages will be supported in the future.
? Update Log
2/24/2026
- Add Dart support
2/13/2026
- Add 1.21.4, 1.20.4, 1.20.1 support.
- Fix audio bugs. Now you can use audio.play to resume audio which pauses.
2/11/2026
- C#: Added C# support.
- 1.21.1: Added 1.21.1 support.
2/10/2026 Alpha-0.5.1
- IO Block Update: Added
mc.io.configmethod for dynamic reconfiguration of IO blocks via scripts.
2/9/2026 Alpha-0.5.0
- Physical IO System: Added
mcapibridge:ioblock for bridging Redstone with external IO.- Input Mode: Control in-game Redstone power from scripts.
- Output Mode: Monitor in-game Redstone power changes in scripts.
- Interactive Config: Right-click to open a GUI for setting Channel ID and Mode.
- Visual Feedback: Block texture changes based on mode (Input/Output).
2/8/2026 Alpha-0.4.1
- Audio & Video Dimension Support: Implemented dimension-aware playback. Screens and 3D audio now correctly isolate between Overworld, Nether, and End.
- Hot-Join & Resume Playback: Added state persistence and offset synchronization. New players joining the server will automatically receive audio data and resume playback in perfect sync with the video.
- Sync Adjustment: Added a slider in the audio settings to manually adjust audio latency compensation (+/- 5.00s).
2/6/2026 Alpha-0.4.0
- Custom Screen System: Introduced
mcapibridge:screenblock for displaying real-time images and video streams.- Video Wall: Supports seamless multi-block screen assembly with automatic layout detection.
- High-Res Streaming: Capable of streaming 1080p/720p content at 30 FPS via JPG/PNG compression.
- Easy Config: Right-click to open a GUI for setting Screen IDs.
- Audio Optimization: Added
audio.clonecommand to efficiently replicate audio sources for multi-speaker setups (e.g., surround sound cinemas) without re-uploading data. - Bugs fixed:
- Fix audio on play3d witch can't set volume to 0 automatically.
- Fix socket can still keep connected with bridges sometimes.
2/4/2026 Alpha-0.3.1
- Audio Settings Integration: Added native "MCAPIBridge Audio" volume slider in Minecraft's Sound Options menu.
2/4/2026 Alpha-0.3.0
- Custom Audio System: Added full audio playback capabilities via OpenAL.
- Tone Generation: Create sine wave tones with configurable frequency and duration.
- WAV Support: Load and play custom
.wavfiles (auto-converts stereo to mono). - 3D Spatial Audio: Play audio at world coordinates with realistic distance attenuation and rolloff control.
- Dynamic Position: Update sound source positions in real-time for surround effects.
- Playback Controls: Volume adjustment, loop toggle, pause, stop, and unload functions.
- Multi-Source: Play multiple audio sources simultaneously for chords and layered audio.
2/1/2026 Alpha-0.2.2
- Deep Data Control: Added NBT modification support for entities and blocks, allowing advanced customization like giant mobs or custom loot.
- Camera Control: Implemented
lookAtAPI to force players or entities to look at specific coordinates.
1/31/2026 Alpha-0.2.1
- Bug Fixed: Single hit or chat event can now be handled by multiple connected scripts.
1/31/2026 Alpha-0.2.0
- Client-Side Input: Now detects Left/Right clicks even when aiming at the air (using client packets).
- Macro Keys: Added 5 customizable keys in the game settings that scripts can listen to for triggering custom actions.
?️ Roadmap
- More Language Bridges: Arduino for ESP32, Micropython for ESP32 libraries.
下载 MCAPIBridge
下载 MCAPIBridge
下载 MCAPIBridge
下载 MCAPIBridge
下载 MCAPIBridge
下载 MCAPIBridge
下载 MCAPIBridge
下载 MCAPIBridge
下载 MCAPIBridge
下载 MCAPIBridge
- 添加对 1.21.4、1.20.4 和 1.20.1 的支持。
- 修复音频错误。现在你可以使用
audio.play来恢复暂停的音频。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
AE2:一款流行的自动化与存储模组
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧