an hackable headless minecraft client, built with aiocraft
Find a file
2023-11-20 19:23:11 +01:00
scripts fix: i actually sorta finished it and added a migration script 2022-08-25 20:03:33 +02:00
src/treepuncher fix: pass login code from CLI 2023-11-20 18:54:50 +01:00
.editorconfig style: moved settings into globals 2022-07-06 12:42:29 +02:00
.gitignore chore: updated build system 2023-06-03 13:43:02 +02:00
LICENSE Initial commit 2021-11-23 11:24:47 +01:00
pyproject.toml fix: lock aiocraft dep version 2023-11-20 18:55:01 +01:00
README.md docs: wording, consistency 2023-11-20 19:23:11 +01:00

treepuncher

an hackable headless Minecraft client, built with aiocraft

Features

  • persistent storage
  • configuration file
  • pluggable plugin system
  • event system with callbacks
  • world processing

Quick Start

treepuncher is still in development and thus not available yet on PyPI, to install it fetch directly from git:

  • pip install "git+https://git.alemi.dev/treepuncher@v0.3.0"

treepuncher can both be run as a pluggable CLI application or as a library, depending on how much you need to customize its behaviour

as an application

treepuncher ships as a standalone CLI application which you can run with python -m treepuncher

  • create your first addon (for example, a simple chat logger) inside ./addons/chat_logger.py
from dataclasses import dataclass
from treepuncher import Addon, ConfigObject
from treepuncher.events import ChatEvent

class ChatLogger(Addon):
	@dataclass
	class Options(ConfigObject):
		prefix : str = ""
	config : Options

	def register(self):
		@self.client.on(ChatEvent)
		async def print_chat(event: ChatEvent):
			print(f"{event.user} >> {event.text})
  • create a config file for your session (for example, my_bot): my_bot.ini
[Treepuncher]
server = your.server.com
username = your_account_username
client_id = your_microsoft_authenticator_client_id
client_secret = your_microsoft_authenticator_client_secret
code = microsoft_auth_code

[ChatLogger]
prefix = CHAT |::
  • run the treepuncher client : python -m treepuncher my_bot (note that session name must be same as config file, minus .ini)

as a library

under the hood treepuncher is just a library and it's possible to invoke it programmatically

  • instantiate the treepuncher object
from treepuncher import Treepuncher

client = Treepuncher(
	"my_bot",
	server="your.server.com",
)
  • prepare your addons (must extend treepuncher.Addon) and install them
from treepuncher import Addon

class MyAddon(Addon):
	pass

addon = MyAddon()
client.install(addon)
  • run your client
client.run()

Authentication

treepuncher supports both legacy Yggdrasil authentication (with options to override session and auth server) and modern Microsoft OAuth authentication. It will store the auth token inside a session file, to restart without requiring credentials again

to be able to use Microsoft authentication you will need to register an Azure application (see community and microsoft docs on how to do that).

this is a tedious process but can be done just once for many accounts, sadly Microsoft decided that only kids play minecraft and we developers should just suffer...

be warned that Microsoft may limit your account if they find your activity suspicious

once you have your client_id and client_secret use this page to generate a login code: put in your client_id and any state and press auth. you will be brought to Microsoft login page, input your credentials, authorize your application and you will be redirected back to the msauth page, but now there should be a code in the auth code field

put this code in your config and you're good to go!

if you'd rather use classic Yggdrasil authentication, consider ftbsc yggdrasil (src)

legacy Yggdrasil authentication supports both an hardcoded password or a pre-authorized access token

Contributing

development is managed by ftbsc, mostly on our git. If you'd like to contribute, get in contact with any of us using any available form