leafish 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. leafish-0.1.0/.gitignore +15 -0
  2. leafish-0.1.0/CHANGELOG.md +67 -0
  3. leafish-0.1.0/CONTRIBUTING.md +36 -0
  4. leafish-0.1.0/IMPLEMENTATION_STATUS.md +172 -0
  5. leafish-0.1.0/LICENSE +21 -0
  6. leafish-0.1.0/PKG-INFO +112 -0
  7. leafish-0.1.0/README.md +79 -0
  8. leafish-0.1.0/ROADMAP.md +70 -0
  9. leafish-0.1.0/docs/api/bot.md +215 -0
  10. leafish-0.1.0/docs/api/index.md +37 -0
  11. leafish-0.1.0/docs/index.md +44 -0
  12. leafish-0.1.0/examples/README.md +16 -0
  13. leafish-0.1.0/examples/collector.py +57 -0
  14. leafish-0.1.0/examples/echo_bot.py +50 -0
  15. leafish-0.1.0/examples/goto_example.py +47 -0
  16. leafish-0.1.0/mkdocs.yml +10 -0
  17. leafish-0.1.0/pyproject.toml +70 -0
  18. leafish-0.1.0/src/leafish/__init__.py +77 -0
  19. leafish-0.1.0/src/leafish/auth/__init__.py +1 -0
  20. leafish-0.1.0/src/leafish/auth/microsoft.py +299 -0
  21. leafish-0.1.0/src/leafish/auth/offline.py +14 -0
  22. leafish-0.1.0/src/leafish/auth/session.py +48 -0
  23. leafish-0.1.0/src/leafish/bot.py +2086 -0
  24. leafish-0.1.0/src/leafish/config.py +57 -0
  25. leafish-0.1.0/src/leafish/data/__init__.py +1 -0
  26. leafish-0.1.0/src/leafish/data/registry.py +236 -0
  27. leafish-0.1.0/src/leafish/data/versions/.gitkeep +0 -0
  28. leafish-0.1.0/src/leafish/data/versions/1.21.11/attributes.json +247 -0
  29. leafish-0.1.0/src/leafish/data/versions/1.21.11/biomes.json +652 -0
  30. leafish-0.1.0/src/leafish/data/versions/1.21.11/blockCollisionShapes.json +146215 -0
  31. leafish-0.1.0/src/leafish/data/versions/1.21.11/blockLoot.json +13199 -0
  32. leafish-0.1.0/src/leafish/data/versions/1.21.11/blocks.json +44682 -0
  33. leafish-0.1.0/src/leafish/data/versions/1.21.11/commands.json +20257 -0
  34. leafish-0.1.0/src/leafish/data/versions/1.21.11/effects.json +242 -0
  35. leafish-0.1.0/src/leafish/data/versions/1.21.11/enchantments.json +980 -0
  36. leafish-0.1.0/src/leafish/data/versions/1.21.11/entities.json +4363 -0
  37. leafish-0.1.0/src/leafish/data/versions/1.21.11/entityLoot.json +1234 -0
  38. leafish-0.1.0/src/leafish/data/versions/1.21.11/foods.json +442 -0
  39. leafish-0.1.0/src/leafish/data/versions/1.21.11/items.json +10026 -0
  40. leafish-0.1.0/src/leafish/data/versions/1.21.11/language.json +7769 -0
  41. leafish-0.1.0/src/leafish/data/versions/1.21.11/loginPacket.json +19819 -0
  42. leafish-0.1.0/src/leafish/data/versions/1.21.11/mapIcons.json +212 -0
  43. leafish-0.1.0/src/leafish/data/versions/1.21.11/materials.json +233 -0
  44. leafish-0.1.0/src/leafish/data/versions/1.21.11/particles.json +462 -0
  45. leafish-0.1.0/src/leafish/data/versions/1.21.11/protocol.json +11655 -0
  46. leafish-0.1.0/src/leafish/data/versions/1.21.11/recipes.json +31864 -0
  47. leafish-0.1.0/src/leafish/data/versions/1.21.11/sounds.json +7354 -0
  48. leafish-0.1.0/src/leafish/data/versions/1.21.11/tints.json +465 -0
  49. leafish-0.1.0/src/leafish/data/versions/1.21.11/version.json +6 -0
  50. leafish-0.1.0/src/leafish/data/versions/1.21.11/windows.json +229 -0
  51. leafish-0.1.0/src/leafish/data/versions/1.21.4/attributes.json +226 -0
  52. leafish-0.1.0/src/leafish/data/versions/1.21.4/biomes.json +652 -0
  53. leafish-0.1.0/src/leafish/data/versions/1.21.4/blockCollisionShapes.json +142311 -0
  54. leafish-0.1.0/src/leafish/data/versions/1.21.4/blockLoot.json +13199 -0
  55. leafish-0.1.0/src/leafish/data/versions/1.21.4/blocks.json +41063 -0
  56. leafish-0.1.0/src/leafish/data/versions/1.21.4/commands.json +18720 -0
  57. leafish-0.1.0/src/leafish/data/versions/1.21.4/effects.json +236 -0
  58. leafish-0.1.0/src/leafish/data/versions/1.21.4/enchantments.json +959 -0
  59. leafish-0.1.0/src/leafish/data/versions/1.21.4/entities.json +4130 -0
  60. leafish-0.1.0/src/leafish/data/versions/1.21.4/entityLoot.json +1234 -0
  61. leafish-0.1.0/src/leafish/data/versions/1.21.4/foods.json +412 -0
  62. leafish-0.1.0/src/leafish/data/versions/1.21.4/items.json +9098 -0
  63. leafish-0.1.0/src/leafish/data/versions/1.21.4/language.json +7002 -0
  64. leafish-0.1.0/src/leafish/data/versions/1.21.4/loginPacket.json +18031 -0
  65. leafish-0.1.0/src/leafish/data/versions/1.21.4/mapIcons.json +212 -0
  66. leafish-0.1.0/src/leafish/data/versions/1.21.4/materials.json +134 -0
  67. leafish-0.1.0/src/leafish/data/versions/1.21.4/particles.json +450 -0
  68. leafish-0.1.0/src/leafish/data/versions/1.21.4/protocol.json +9456 -0
  69. leafish-0.1.0/src/leafish/data/versions/1.21.4/recipes.json +29693 -0
  70. leafish-0.1.0/src/leafish/data/versions/1.21.4/sounds.json +6606 -0
  71. leafish-0.1.0/src/leafish/data/versions/1.21.4/tints.json +422 -0
  72. leafish-0.1.0/src/leafish/data/versions/1.21.4/version.json +6 -0
  73. leafish-0.1.0/src/leafish/data/versions/1.21.4/windows.json +229 -0
  74. leafish-0.1.0/src/leafish/entities/__init__.py +1 -0
  75. leafish-0.1.0/src/leafish/entities/entity.py +162 -0
  76. leafish-0.1.0/src/leafish/entities/manager.py +197 -0
  77. leafish-0.1.0/src/leafish/events/__init__.py +1 -0
  78. leafish-0.1.0/src/leafish/events/emitter.py +176 -0
  79. leafish-0.1.0/src/leafish/events/events.py +63 -0
  80. leafish-0.1.0/src/leafish/exceptions.py +81 -0
  81. leafish-0.1.0/src/leafish/inventory/__init__.py +1 -0
  82. leafish-0.1.0/src/leafish/inventory/inventory.py +230 -0
  83. leafish-0.1.0/src/leafish/inventory/item.py +62 -0
  84. leafish-0.1.0/src/leafish/modules/__init__.py +1 -0
  85. leafish-0.1.0/src/leafish/modules/actions.py +625 -0
  86. leafish-0.1.0/src/leafish/modules/anvil.py +137 -0
  87. leafish-0.1.0/src/leafish/modules/chat.py +121 -0
  88. leafish-0.1.0/src/leafish/modules/client.py +269 -0
  89. leafish-0.1.0/src/leafish/modules/collector.py +86 -0
  90. leafish-0.1.0/src/leafish/modules/containers.py +268 -0
  91. leafish-0.1.0/src/leafish/modules/crafting.py +446 -0
  92. leafish-0.1.0/src/leafish/modules/creative.py +94 -0
  93. leafish-0.1.0/src/leafish/modules/farming.py +131 -0
  94. leafish-0.1.0/src/leafish/modules/fishing.py +161 -0
  95. leafish-0.1.0/src/leafish/modules/health.py +31 -0
  96. leafish-0.1.0/src/leafish/modules/movement.py +165 -0
  97. leafish-0.1.0/src/leafish/modules/pathfinder.py +257 -0
  98. leafish-0.1.0/src/leafish/modules/physics.py +265 -0
  99. leafish-0.1.0/src/leafish/modules/player.py +146 -0
  100. leafish-0.1.0/src/leafish/modules/pvp.py +192 -0
  101. leafish-0.1.0/src/leafish/modules/scoreboard.py +121 -0
  102. leafish-0.1.0/src/leafish/modules/smelting.py +163 -0
  103. leafish-0.1.0/src/leafish/modules/state.py +118 -0
  104. leafish-0.1.0/src/leafish/modules/windows.py +327 -0
  105. leafish-0.1.0/src/leafish/pathfinder/__init__.py +27 -0
  106. leafish-0.1.0/src/leafish/pathfinder/goals.py +268 -0
  107. leafish-0.1.0/src/leafish/plugins/__init__.py +177 -0
  108. leafish-0.1.0/src/leafish/protocol/__init__.py +1 -0
  109. leafish-0.1.0/src/leafish/protocol/compression.py +58 -0
  110. leafish-0.1.0/src/leafish/protocol/connection.py +210 -0
  111. leafish-0.1.0/src/leafish/protocol/encryption.py +75 -0
  112. leafish-0.1.0/src/leafish/protocol/framing.py +259 -0
  113. leafish-0.1.0/src/leafish/protocol/protodef.py +145 -0
  114. leafish-0.1.0/src/leafish/protocol/session.py +290 -0
  115. leafish-0.1.0/src/leafish/protocol/versions/__init__.py +1 -0
  116. leafish-0.1.0/src/leafish/utils/__init__.py +1 -0
  117. leafish-0.1.0/src/leafish/utils/geometry.py +173 -0
  118. leafish-0.1.0/src/leafish/utils/math.py +38 -0
  119. leafish-0.1.0/src/leafish/utils/nbt.py +477 -0
  120. leafish-0.1.0/src/leafish/utils/text.py +71 -0
  121. leafish-0.1.0/src/leafish/utils/vectors.py +145 -0
  122. leafish-0.1.0/src/leafish/version.py +86 -0
  123. leafish-0.1.0/src/leafish/world/__init__.py +1 -0
  124. leafish-0.1.0/src/leafish/world/block.py +59 -0
  125. leafish-0.1.0/src/leafish/world/chunk_codec.py +231 -0
  126. leafish-0.1.0/src/leafish/world/world.py +442 -0
  127. leafish-0.1.0/tests/__init__.py +0 -0
  128. leafish-0.1.0/tests/chunkdata.py +89 -0
  129. leafish-0.1.0/tests/fixtures/__init__.py +0 -0
  130. leafish-0.1.0/tests/integration/__init__.py +0 -0
  131. leafish-0.1.0/tests/integration/test_bot_connect.py +272 -0
  132. leafish-0.1.0/tests/integration/test_containers.py +92 -0
  133. leafish-0.1.0/tests/integration/test_crafting.py +150 -0
  134. leafish-0.1.0/tests/integration/test_cursor.py +40 -0
  135. leafish-0.1.0/tests/integration/test_fishing.py +97 -0
  136. leafish-0.1.0/tests/integration/test_game_state.py +147 -0
  137. leafish-0.1.0/tests/integration/test_smelting.py +66 -0
  138. leafish-0.1.0/tests/protocol/__init__.py +0 -0
  139. leafish-0.1.0/tests/protocol/fake_server.py +687 -0
  140. leafish-0.1.0/tests/unit/__init__.py +0 -0
  141. leafish-0.1.0/tests/unit/test_chunk_codec.py +83 -0
  142. leafish-0.1.0/tests/unit/test_crafting.py +97 -0
  143. leafish-0.1.0/tests/unit/test_creative.py +74 -0
  144. leafish-0.1.0/tests/unit/test_emitter.py +90 -0
  145. leafish-0.1.0/tests/unit/test_entities.py +53 -0
  146. leafish-0.1.0/tests/unit/test_exceptions.py +33 -0
  147. leafish-0.1.0/tests/unit/test_farming.py +90 -0
  148. leafish-0.1.0/tests/unit/test_geometry.py +48 -0
  149. leafish-0.1.0/tests/unit/test_goals.py +108 -0
  150. leafish-0.1.0/tests/unit/test_math.py +29 -0
  151. leafish-0.1.0/tests/unit/test_nbt.py +38 -0
  152. leafish-0.1.0/tests/unit/test_pathfinder.py +97 -0
  153. leafish-0.1.0/tests/unit/test_physics.py +122 -0
  154. leafish-0.1.0/tests/unit/test_plugins.py +163 -0
  155. leafish-0.1.0/tests/unit/test_pvp.py +134 -0
  156. leafish-0.1.0/tests/unit/test_scoreboard_handlers.py +156 -0
  157. leafish-0.1.0/tests/unit/test_vectors.py +53 -0
  158. leafish-0.1.0/tests/unit/test_windows.py +151 -0
  159. leafish-0.1.0/tools/fetch_mcdata.py +120 -0
@@ -0,0 +1,15 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .venv/
7
+ venv/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ .coverage
11
+ htmlcov/
12
+ site/
13
+ *.log
14
+ .env
15
+ .leafish/
@@ -0,0 +1,67 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented here.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Project scaffolding: packaging, lint/type/test tooling, docs skeleton.
12
+ - Core exception hierarchy, configuration, vector/math/NBT utilities.
13
+ - Async event emitter with async handler support and error isolation.
14
+ - Protocol stack: packet framing, compression, AES/CFB8 encryption,
15
+ ProtoDef serialization via `protolib`, full state machine
16
+ (handshaking/status/login/configuration/play).
17
+ - Authentication: offline mode + Microsoft device-code/OAuth/Xbox Live/XSTS
18
+ flow.
19
+ - Vendored minecraft-data for Java 1.21.11 (protocol 774) and version registry.
20
+ - `LeafishBot`: connect/spawn/chat/movement/health, entity tracking,
21
+ inventory model, world model, physics engine.
22
+ - World: chunk column/section decoding with palette containers
23
+ (single/indirect/direct), block search, raycast, block updates.
24
+ - Actions: digging, block placement, attack, equip.
25
+ - Physics: AABB collision, ground detection, fluid movement.
26
+ - Pathfinder: A* with step-ups and `goto` execution.
27
+ - Crafting: shaped/shapeless recipes via 2x2 grid clicks; fake server
28
+ gained an inventory model and minimal recipe matching.
29
+ - Combat (`bot.pvp`), fishing (`bot.fish`), item collection
30
+ (`bot.collect`), farming (`bot.harvest`/`plant`/`tend_farm`).
31
+ - Plugins (`bot.load_plugin`), `Leafish.create_bots`, examples,
32
+ disconnect cleanup for physics.
33
+ - Container windows: `bot.open_window`/`close_window`/`shift_click`/
34
+ `window_click` with per-window slot stores, `windows.json` layouts,
35
+ and fake-server shift-click simulation.
36
+ - Crafting tables: 3x3 recipes (e.g. diamond_pickaxe) craft inside an
37
+ open crafting-table window via `bot.craft(..., crafting_table=True)`.
38
+ - Container helpers (`bot.deposit_all`/`bot.withdraw`) and anvil repair
39
+ (`bot.repair`) with fake-server anvil simulation.
40
+ - Fake protocol server + end-to-end integration tests.
41
+ - `tools/fetch_mcdata.py` for vendoring minecraft-data JSON.
42
+ - Complete interaction surface: `use_item`, `consume`,
43
+ `activate_item`/`deactivate_item`, entity/block interactions,
44
+ signs, books, tab-complete, resource packs, respawn, sleep/wake,
45
+ elytra, mount/dismount/vehicle steering.
46
+ - Bot state objects & properties: game info, abilities, world time,
47
+ experience, weather, settings, physics toggle, scoreboard/team/
48
+ boss-bar collections.
49
+ - Typed windows (`bot.open_window` → `FurnaceWindow`,
50
+ `EnchantmentTableWindow`, `AnvilWindow`, `VillagerWindow`,
51
+ `HorseWindow`) with progress/trade/rename APIs.
52
+ - `bot.creative` namespace for creative-mode inventory ops.
53
+ - `leafish.pathfinder` goals package (`GoalNear`, `GoalFollow`,
54
+ `GoalComposite`, ...) with dynamic-goal replanning.
55
+ - `@plugin` decorator with dependencies and override protection.
56
+ - New packet handlers: boss bars, teams, scoreboards, titles,
57
+ particles, sounds, vehicles, block actions, item pickup, combat
58
+ events, window properties, trades, horse windows.
59
+ - Chunk light accessors (`world.light_at`), entity bounding boxes,
60
+ tool-aware dig times.
61
+ - Fixed: `Particle` data switch missing `default: void` in vendored
62
+ protocol data (broke particle encode/decode).
63
+ - Cursor/line-of-sight helpers: `bot.blockAtCursor`, `bot.entityAtCursor`,
64
+ entity AABB queries, `utils.geometry` ray-vs-AABB helper.
65
+ - `bot.smelt(...)` furnace workflow (`SmeltingModule`) driving
66
+ `FurnaceWindow` typed view; fake server now simulates furnace
67
+ burn/cook ticks and container window clicks.
@@ -0,0 +1,36 @@
1
+ # Contributing to Leafish
2
+
3
+ Thanks for your interest in contributing! Leafish is a pure Python,
4
+ asynchronous Minecraft Java Edition bot framework.
5
+
6
+ ## Development setup
7
+
8
+ ```bash
9
+ git clone https://github.com/leafish/leafish
10
+ cd leafish
11
+ pip install -e ".[dev]"
12
+ ```
13
+
14
+ ## Workflow
15
+
16
+ 1. Create a branch for your change.
17
+ 2. Write tests for new behavior (`tests/unit`, `tests/integration`,
18
+ `tests/protocol`).
19
+ 3. Run the checks:
20
+
21
+ ```bash
22
+ pytest
23
+ ruff check
24
+ ty check
25
+ ```
26
+
27
+ 4. Update `IMPLEMENTATION_STATUS.md` if you change what the project can do.
28
+ 5. Open a pull request.
29
+
30
+ ## Rules of the road
31
+
32
+ - Protocol packet IDs and layouts must come from minecraft-data
33
+ (`protocol.json`) — never hardcode guessed values.
34
+ - No feature is "done" without tests.
35
+ - Keep secrets (tokens, passwords) out of logs and code.
36
+ - Public APIs need type annotations and docstrings.
@@ -0,0 +1,172 @@
1
+ # Implementation Status
2
+
3
+ This file is the source of truth for what Leafish can actually do today.
4
+ Nothing is listed as complete unless it is implemented and covered by tests.
5
+
6
+ Legend: ✅ done · 🚧 partial · ⬜ not started · ❌ unsupported/known issue
7
+
8
+ ## Phase 0 — Scaffolding
9
+ - ✅ Package skeleton (`src/leafish`), `pyproject.toml`, pytest/ruff/ty config
10
+ - ✅ README, LICENSE, CONTRIBUTING, CHANGELOG, ROADMAP
11
+ - ✅ Git repository initialized
12
+
13
+ ## Phase 1 — Foundation
14
+ - ✅ Exception hierarchy (`LeafishError` and subclasses)
15
+ - ✅ Configuration (`BotConfig`)
16
+ - ✅ `Vec3`/`Vec2`/`BlockPos`, math, geometry, raycast helpers
17
+ - ✅ NBT parse/serialize (SNBT + binary)
18
+ - ✅ Async event emitter (`on`/`once`/`off`/`wait_for`/`emit`, error isolation)
19
+ - ✅ Chat text component → plain text conversion
20
+
21
+ ## Phase 2 — Protocol
22
+ - ✅ VarInt/VarLong encode/decode, packet framing, max-size validation
23
+ - ✅ Compression (threshold + zlib)
24
+ - ✅ AES/CFB8 encryption (login handshake shared secret + transport cipher)
25
+ - ✅ ProtoDef serialization via `protolib` (all Minecraft composite types:
26
+ slots, entity metadata, NBT, registry holders, bitflags, etc.)
27
+ - ✅ Protocol states & transitions (handshaking/status/login/configuration/play)
28
+ - ✅ Login flow: offline mode, encryption request/response, login success,
29
+ compression negotiation, disconnect handling
30
+ - ✅ Configuration-state packets (finish configuration, registry data stubs)
31
+ - ✅ Keepalive
32
+ - ✅ Version registry + vendored minecraft-data JSON loader
33
+ - ✅ Fake asyncio protocol server for hermetic integration tests
34
+ - 🚧 Microsoft authentication: device-code OAuth → Xbox Live → XSTS →
35
+ Minecraft Services implemented, not yet verified against live services
36
+ - 🚧 Some play-state packet handlers are stubs/partial (see Phase 3-5)
37
+
38
+ ## Phase 2b — Minecraft data
39
+ - ✅ Vendored `minecraft-data` JSON for Java 1.21.11 (protocol 774):
40
+ blocks, items, entities, recipes, biomes, windows, effects, attributes,
41
+ particles, sounds, languages, etc.
42
+ - ✅ Registry computes block-state IDs from property descriptors
43
+ - ⬜ Additional versions
44
+
45
+ ## Phase 3 — Basic bot
46
+ - ✅ `LeafishBot` orchestration: connect, spawn, chat send/receive,
47
+ position tracking, health/hunger/experience updates
48
+ - ✅ Movement module (position/look/ground packets, teleport confirm)
49
+ - ✅ Physics engine (AABB collision, axis-separated movement, ground
50
+ detection, fluid drag, `physics.enabled` toggle)
51
+ - ✅ Full interaction surface: `use_item`, `consume`,
52
+ `activate_item`/`deactivate_item`, `use_on`, `activate_entity`,
53
+ `activate_block`, `place_entity`, signs (`update_sign`), books,
54
+ tab-complete, resource-pack responses, command blocks, respawn,
55
+ sleep/wake, elytra, mount/dismount/vehicle steering
56
+ - ✅ State objects/properties: `game`, `abilities`, `time`,
57
+ `experience`, `health`/`food`/`food_saturation`/`oxygen`,
58
+ `weather`, `settings`, `physics_enabled`, `is_sleeping`,
59
+ `spawn_point`, `tablist`, `quick_bar_slot`, `target_dig_block`,
60
+ `cursor_item`, `has_plugin`/`load_plugins`
61
+ - ✅ End-to-end integration test vs fake server (connect → spawn → chat →
62
+ move) plus game-state packet tests (boss bars, teams, scoreboards,
63
+ titles, particles, vehicles)
64
+ - 🚧 Entity tracking: spawn/despawn/metadata/equipment/velocity/teleport
65
+ handled; entity effects, passengers and vehicles tracked; richer
66
+ entity-type behaviors (AI, attributes) partial
67
+
68
+ ## Phase 4 — World & entities
69
+ - ✅ World model: chunk columns, palette-container section decoding
70
+ (single/indirect/direct), block get/set API, block search, raycast
71
+ - ✅ Entities: typed entity classes (Player/Mob/ItemEntity/Projectile/
72
+ Vehicle) classified from versioned type ids, movement/metadata/
73
+ equipment tracking, nearest-entity queries
74
+ - ✅ Modern 1.21.x chunk column decoding (heightmaps, block entities,
75
+ light masks parsed; sky/block light stored and exposed via
76
+ `world.light_at(pos)` returning `(sky, block)` levels)
77
+ - ✅ Raycast against loaded world
78
+ - ✅ Entity bounding boxes and `contains_point`/`entity_at` lookups
79
+
80
+ ## Phase 5 — Inventory & interaction
81
+ - ✅ Inventory model: slots, items, equipment tracking, `toss`,
82
+ `toss_stack`, `unequip`, `move_slot_item`, `put_away`, `transfer`,
83
+ `put_selected_item_range`, `simple_click`
84
+ - ✅ Window/container model: open/close tracking, `set_slot`/`window_items`
85
+ state sync, container slot ranges from `windows.json`
86
+ - ✅ Typed windows: `Window` base + `FurnaceWindow` (burn/cook progress),
87
+ `EnchantmentTableWindow` (`enchant`), `AnvilWindow` (`rename`,
88
+ repair cost), `VillagerWindow` (trades, `select_trade`),
89
+ `HorseWindow`; `bot.open_window`/`open_furnace`/`open_enchantment_table`/
90
+ `open_anvil`/`open_villager`/`current_window`
91
+ - ✅ `bot.creative` namespace: `set_slot`/`give`/`clear`/`set_held_item`
92
+ via `set_creative_slot`
93
+ - ✅ Window clicks: mode-0 (pickup/place/merge), mode-1 (shift-click
94
+ transfer), mode-2 (hotbar swap) with per-window state-id sync
95
+ - ✅ Container helpers: `deposit_all`/`withdraw` bulk transfers
96
+ - ✅ Anvil: `bot.repair` places tool+material and takes the result
97
+ (server-authoritative; fake server simulates result generation)
98
+ - ✅ Crafting: shaped + shapeless recipes via the 2x2 inventory grid and
99
+ 3x3 crafting-table windows (`crafting_table=True` with an open table)
100
+ - ✅ Smelting: `bot.smelt` drives `FurnaceWindow` (input/fuel/output
101
+ slots, burn/cook progress); server-authoritative, no client recipe
102
+ table needed
103
+ - ✅ Cursor & line-of-sight: `bot.blockAtCursor`/`bot.entityAtCursor`,
104
+ `utils.geometry` ray-vs-AABB intersection, entity bounding boxes
105
+ - ✅ Digging (`start_dig`/`stop_dig`/`dig` with status packets + local
106
+ state), block placement with face/direction handling
107
+ - ✅ Item collection (`bot.collect` paths to nearby item entities)
108
+ - ✅ Attack (`attack`) and equip (`equip`) actions
109
+
110
+ ## Phase 6 — Automation
111
+ - ✅ Pathfinder: A* over the collision grid with step-ups, `goto`
112
+ execution with stuck detection and replan
113
+ - ✅ Pathfinder goals package (`leafish.pathfinder`): `GoalBlock`,
114
+ `GoalNear`, `GoalXZ`/`GoalNearXZ`, `GoalY`, `GoalGetToBlock`,
115
+ `GoalLookAtBlock`, `GoalFollow`/`GoalFollowEntity`, `GoalComposite`,
116
+ `GoalInvert`; dynamic goals replan as targets move
117
+ - ✅ Combat: `bot.pvp` target acquisition + engage loop with pathfinder
118
+ approach and attack cooldown; `bot.attack` for single hits
119
+ - ✅ Fishing: `bot.fish` cast/bite/reel with best-effort bite detection
120
+ - ✅ Farming: `bot.harvest`/`bot.plant`/`bot.tend_farm` for
121
+ wheat/carrots/potatoes/beetroots (no hoe-tilling yet)
122
+
123
+ ## Phase 7 — Extensibility
124
+ - ✅ Plugin loader: `bot.load_plugin` / `unload_plugin` for callables and
125
+ inject/unload objects
126
+ - ✅ `@plugin` decorator with `name`/`dependencies`/`overrides` metadata;
127
+ dependency auto-resolution and undeclared-override protection
128
+ - ✅ Multiple bot instances: independent `LeafishBot`s plus
129
+ `Leafish.create_bots` for concurrent creation
130
+ - ✅ Examples: `examples/` (echo bot, goto, collector) — runnable against
131
+ a real server, not covered by automated tests
132
+
133
+ ## Game-state models
134
+ - ✅ `ScoreBoard`/`ScoreItem`, `Team`, `BossBar`, `Particle` in
135
+ `modules/scoreboard.py` with `scoreboard_*`, `teams`, `boss_bar`,
136
+ `world_particles`, `craft_progress_bar`, `trade_list`,
137
+ `open_horse_window` packet handlers
138
+ - ✅ Combat/damage events: `hurt_animation`, `damage_event`,
139
+ `death_combat_event`, combat enter/end
140
+ - ✅ Vehicle tracking: `attach_entity`, `set_passengers`, mount/dismount
141
+ - ✅ Item pickup (`collect` → `player_collect`/`item_collected`),
142
+ block actions (pistons, note blocks, container lids), block-break
143
+ progress, titles, sounds, entity effects, tags, books, maps
144
+
145
+ ## Phase 8 — Compatibility & release
146
+ - ⬜ Additional versions
147
+ - ⬜ Performance pass
148
+ - ✅ Docs: MkDocs site builds cleanly (index + API reference pages)
149
+ - 🚧 pip-installable package metadata present; not yet released
150
+
151
+ ## Version compatibility
152
+
153
+ | Minecraft version | Protocol | Status |
154
+ |---|---|---|
155
+ | Java 1.21.11 | 774 | 🚧 connect/spawn/chat/move verified vs fake server; real-server validation pending |
156
+ | Java 1.21.4 | 769 | 🚧 connect/spawn/chat smoke test vs fake server |
157
+
158
+ ## Known limitations / bugs
159
+ - Chunk light data is exposed via accessors but per-block lighting
160
+ queries and dynamic light are not implemented.
161
+ - Chunk data does not yet handle every 1.21.x edge case (e.g. some
162
+ multi-block-change variants).
163
+ - Microsoft auth flow is implemented but unverified against live Xbox Live
164
+ endpoints.
165
+ - Encryption path is implemented but only exercised by unit-level tests,
166
+ not a real encrypted server.
167
+ - Enchantment offers are best-effort (decoded from slot components);
168
+ there is no dedicated enchant-options packet in 1.21.11.
169
+ - `GoalInvert` and `GoalY`/`GoalXZ` pathing is approximate; physics is
170
+ client-predicted and the server remains authoritative.
171
+ - Some play-state packets are still acknowledged and emitted as generic
172
+ events without dedicated handling (e.g. map data, recipe book UI).
leafish-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Leafish contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
leafish-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.5
2
+ Name: leafish
3
+ Version: 0.1.0
4
+ Summary: A pure Python, asynchronous Minecraft Java Edition bot framework inspired by Mineflayer.
5
+ Project-URL: Homepage, https://github.com/leafish/leafish
6
+ Author: Leafish contributors
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: asyncio,bot,minecraft,protocol
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Games/Entertainment
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: cryptography>=42
20
+ Requires-Dist: httpx>=0.27
21
+ Requires-Dist: protolib>=0.4
22
+ Provides-Extra: dev
23
+ Requires-Dist: build>=1.0; extra == 'dev'
24
+ Requires-Dist: hypothesis>=6; extra == 'dev'
25
+ Requires-Dist: mkdocs-material>=9.5; extra == 'dev'
26
+ Requires-Dist: mkdocs>=1.5; extra == 'dev'
27
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
28
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
29
+ Requires-Dist: pytest>=8; extra == 'dev'
30
+ Requires-Dist: ruff>=0.5; extra == 'dev'
31
+ Requires-Dist: ty>=0.0.1a0; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # Leafish
35
+
36
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
37
+
38
+ A pure Python, asynchronous Minecraft Java Edition bot framework inspired by
39
+ [Mineflayer](https://github.com/PrismarineJS/mineflayer).
40
+
41
+ Leafish lets you programmatically control Minecraft Java Edition clients from
42
+ Python: join servers, chat, move, mine, build, craft, fight, and automate —
43
+ all through a modern `asyncio` API with an event-driven architecture.
44
+
45
+ ## Features (planned / in progress)
46
+
47
+ See [IMPLEMENTATION_STATUS.md](IMPLEMENTATION_STATUS.md) for the honest,
48
+ current state of every subsystem.
49
+
50
+ - Native Minecraft Java Edition protocol implementation (no Node.js, no
51
+ external bot process)
52
+ - Offline and Microsoft authentication
53
+ - Async, event-driven API with plugin support
54
+ - World, chunk, entity, and inventory tracking
55
+ - Pathfinding, digging, placing, crafting, combat, containers
56
+ - Multi-version protocol support driven by vendored minecraft-data
57
+
58
+ ## Requirements
59
+
60
+ - Python 3.11+
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ pip install leafish
66
+ ```
67
+
68
+ For development:
69
+
70
+ ```bash
71
+ git clone https://github.com/leafish/leafish
72
+ cd leafish
73
+ pip install -e ".[dev]"
74
+ ```
75
+
76
+ ## Quick start
77
+
78
+ ```python
79
+ import asyncio
80
+ from leafish import Leafish
81
+
82
+ async def main():
83
+ bot = await Leafish.create_bot(
84
+ host="localhost",
85
+ port=25565,
86
+ username="Leafish",
87
+ auth="offline",
88
+ )
89
+
90
+ @bot.on("spawn")
91
+ async def on_spawn():
92
+ print("Leafish joined the world!")
93
+
94
+ @bot.on("chat")
95
+ async def on_chat(username, message):
96
+ print(f"<{username}> {message}")
97
+
98
+ await bot.wait_until_disconnected()
99
+
100
+ asyncio.run(main())
101
+ ```
102
+
103
+ ## Status
104
+
105
+ Leafish is under active development. The protocol layer, bot API, world model,
106
+ and automation modules are implemented incrementally — check
107
+ [ROADMAP.md](ROADMAP.md) and [IMPLEMENTATION_STATUS.md](IMPLEMENTATION_STATUS.md)
108
+ for details. Features are not advertised until they are implemented and tested.
109
+
110
+ ## License
111
+
112
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,79 @@
1
+ # Leafish
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
4
+
5
+ A pure Python, asynchronous Minecraft Java Edition bot framework inspired by
6
+ [Mineflayer](https://github.com/PrismarineJS/mineflayer).
7
+
8
+ Leafish lets you programmatically control Minecraft Java Edition clients from
9
+ Python: join servers, chat, move, mine, build, craft, fight, and automate —
10
+ all through a modern `asyncio` API with an event-driven architecture.
11
+
12
+ ## Features (planned / in progress)
13
+
14
+ See [IMPLEMENTATION_STATUS.md](IMPLEMENTATION_STATUS.md) for the honest,
15
+ current state of every subsystem.
16
+
17
+ - Native Minecraft Java Edition protocol implementation (no Node.js, no
18
+ external bot process)
19
+ - Offline and Microsoft authentication
20
+ - Async, event-driven API with plugin support
21
+ - World, chunk, entity, and inventory tracking
22
+ - Pathfinding, digging, placing, crafting, combat, containers
23
+ - Multi-version protocol support driven by vendored minecraft-data
24
+
25
+ ## Requirements
26
+
27
+ - Python 3.11+
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ pip install leafish
33
+ ```
34
+
35
+ For development:
36
+
37
+ ```bash
38
+ git clone https://github.com/leafish/leafish
39
+ cd leafish
40
+ pip install -e ".[dev]"
41
+ ```
42
+
43
+ ## Quick start
44
+
45
+ ```python
46
+ import asyncio
47
+ from leafish import Leafish
48
+
49
+ async def main():
50
+ bot = await Leafish.create_bot(
51
+ host="localhost",
52
+ port=25565,
53
+ username="Leafish",
54
+ auth="offline",
55
+ )
56
+
57
+ @bot.on("spawn")
58
+ async def on_spawn():
59
+ print("Leafish joined the world!")
60
+
61
+ @bot.on("chat")
62
+ async def on_chat(username, message):
63
+ print(f"<{username}> {message}")
64
+
65
+ await bot.wait_until_disconnected()
66
+
67
+ asyncio.run(main())
68
+ ```
69
+
70
+ ## Status
71
+
72
+ Leafish is under active development. The protocol layer, bot API, world model,
73
+ and automation modules are implemented incrementally — check
74
+ [ROADMAP.md](ROADMAP.md) and [IMPLEMENTATION_STATUS.md](IMPLEMENTATION_STATUS.md)
75
+ for details. Features are not advertised until they are implemented and tested.
76
+
77
+ ## License
78
+
79
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,70 @@
1
+ # Roadmap
2
+
3
+ ## Phase 0 — Foundation & scaffolding
4
+ - [x] Project structure, packaging, lint/type/test tooling
5
+ - [x] README, LICENSE, CONTRIBUTING, CHANGELOG
6
+ - [x] ROADMAP / IMPLEMENTATION_STATUS tracking
7
+
8
+ ## Phase 1 — Core foundation
9
+ - [x] Exception hierarchy
10
+ - [x] Configuration
11
+ - [x] Vector / math / geometry utilities
12
+ - [x] NBT parsing & serialization
13
+ - [x] Async event emitter
14
+
15
+ ## Phase 2 — Protocol stack
16
+ - [x] VarInt/VarLong, packet framing, size limits
17
+ - [x] Packet compression (zlib threshold)
18
+ - [x] AES/CFB8 encryption
19
+ - [x] ProtoDef schema compiler driven by minecraft-data `protocol.json`
20
+ - [x] Connection state machine (handshake → status → login → configuration → play)
21
+ - [x] Keepalive handling
22
+ - [x] Versioned protocol adapters + vendored minecraft-data
23
+ - [ ] Full coverage of per-version custom packet types
24
+
25
+ ## Phase 3 — Basic bot
26
+ - [x] Bot creation API (`Leafish.create_bot`)
27
+ - [x] Spawn/login/configuration handling
28
+ - [x] Chat send/receive
29
+ - [x] Movement controls, look/look_at
30
+ - [x] Position tracking, health, hunger
31
+
32
+ ## Phase 4 — World & entities
33
+ - [x] Chunk decoding, sections, palettes, light data
34
+ - [x] Block registry & lookups
35
+ - [x] Entity registry & tracking
36
+ - [x] Raycasting / line of sight
37
+
38
+ ## Phase 5 — Inventory & interaction
39
+ - [x] Inventory/items/windows/transactions
40
+ - [x] Block digging & placement
41
+ - [x] Containers
42
+ - [x] Item collection
43
+
44
+ ## Phase 6 — Automation
45
+ - [x] Crafting + recipe planner
46
+ - [x] Physics (movement, collision)
47
+ - [x] Pathfinder (A*, goals, movements)
48
+ - [x] Combat
49
+ - [x] Fishing, farming
50
+
51
+ ## Phase 7 — Extensibility
52
+ - [x] Plugin framework
53
+ - [x] Multi-bot manager
54
+ - [x] Examples
55
+
56
+ ## Phase 8 — Compatibility & release
57
+ - [ ] Additional protocol versions
58
+ - [ ] Performance pass
59
+ - [x] Full documentation (MkDocs)
60
+ - [ ] Release
61
+
62
+ ## Parity backlog (reference_api.md)
63
+ - [x] Typed windows (Furnace, EnchantmentTable, Villager, Anvil, Horse)
64
+ - [x] Pathfinder goal classes (`leafish.pathfinder.goals`)
65
+ - [x] `bot.creative` namespace
66
+ - [x] Scoreboards / teams / boss bars / particles
67
+ - [x] Bot state objects (game/time/XP/abilities/weather/settings)
68
+ - [x] Plugin `@plugin` decorator with dependencies + override guard
69
+ - [ ] Remaining niche parity items: recipe-book UI sync, map data,
70
+ boss-bar style edge cases, entity AI/attribute behaviors