Skip to main content

Minecraft Bedrock WebSocket

Project description

py-mcws

PyPI - Version Downloads PyPI - License Upload Python Package

MinecraftとPythonを繋げるためのシンプルなライブラリ


インストール

pip install py-mcws

使い方

import py_mcws

server = py_mcws.WebsocketServer()


@server.event
async def on_ready(host, port):
    print("サーバーを起動しました。")
    print(f"'/connect {host}:{port}' で接続できます")


@server.event
async def on_connect():
    print("接続しました")
    await server.command("say Hello World!") # メッセージを送信


@server.event
async def on_PlayerMessage(event):
    print(event)

server.start(host="0.0.0.0", port=19132)

接続の仕方

[!WARNING] ワールドの設定でチートを有効にする必要があります。

Minecraft内のチャットで以下のコマンドを実行してください。

/connect host:port

イベントを受け取る

[!NOTE] Minecraftで受け取れるイベントは以下から確認してください。
MCPE & W10 Event Names by jocopa3

PlayerMessageイベントを受け取る例

@server.event
async def on_PlayerMessage(event):
    print(event)

コマンドを実行する

Minecraft と接続している状態でコマンドを実行してください。

cmd = await server.command("say Hello World!")
print(cmd)

記事

以下の記事は、inunosinsiさんによる記事です。
thanks!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-mcws-2.0.2.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

py_mcws-2.0.2-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page