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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file py-mcws-2.0.2.tar.gz.

File metadata

  • Download URL: py-mcws-2.0.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for py-mcws-2.0.2.tar.gz
Algorithm Hash digest
SHA256 4888a6f44d93b497f044f9350528a4c3975951738bbe5f6ac3acf5bdf097a2ff
MD5 68abb7f9c7155f4c9d0214ff4cf2b7a1
BLAKE2b-256 bdbe7493949059641d203227022c5703d31d581beafaf66045c3fc5e2c533212

See more details on using hashes here.

File details

Details for the file py_mcws-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: py_mcws-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for py_mcws-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 37c7a484433c625a62cd1441a87f318186271181b264ac4fae05b253e832bb42
MD5 9b1347e3b935eba72d8b0684306d01d3
BLAKE2b-256 15147fc7964b0bcf375bb06cec40f5c6733919a5acb4c977e650e3d79cb889c1

See more details on using hashes here.

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