@mcbe-mods/protocol
v1.0.0-beta.3
Published
Bedrock protocol transport layer for MCBE Script API
Downloads
48
Maintainers
Readme
@mcbe-mods/protocol
bedrock:// transport layer for Minecraft Bedrock Edition Script API.
Wraps system.sendScriptEvent and scriptEventReceive into a simple Pub/Sub API.
Install
npm install @mcbe-mods/protocolUsage
import { Protocol } from '@mcbe-mods/protocol'
const protocol = new Protocol()
// Subscribe to incoming messages
const unsubscribe = protocol.onReceive((event) => {
event.url // BedrockURL
event.message // string payload
event.sourceType // 'Server' | 'Client' | 'Other'
})
// Send a message
protocol.post('bedrock://my-addon/info', 'hello')
protocol.get('bedrock://my-addon/ping')
// Cleanup
unsubscribe()
protocol.dispose()