Skip to main content

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!

Metadata

Release files for py-mcws 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-mcws 2.0.2
File Size Uploaded
py-mcws-2.0.2.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-mcws 2.0.2
File Interpreter ABI Platform
py_mcws-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / py-mcws-2.0.2.tar.gz

Download URL py-mcws-2.0.2.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4888a6f44d93b497f044f9350528a4c3975951738bbe5f6ac3acf5bdf097a2ff
BLAKE2b-256 checksum
How to use checksums
bdbe7493949059641d203227022c5703d31d581beafaf66045c3fc5e2c533212
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / py_mcws-2.0.2-py3-none-any.whl

Download URL py_mcws-2.0.2-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37c7a484433c625a62cd1441a87f318186271181b264ac4fae05b253e832bb42
BLAKE2b-256 checksum
How to use checksums
15147fc7964b0bcf375bb06cec40f5c6733919a5acb4c977e650e3d79cb889c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.2

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page