mineflex 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 (87) hide show
  1. mineflex-0.1.0/LICENSE +21 -0
  2. mineflex-0.1.0/PKG-INFO +147 -0
  3. mineflex-0.1.0/README.md +109 -0
  4. mineflex-0.1.0/mineflex/__init__.py +48 -0
  5. mineflex-0.1.0/mineflex/actions/__init__.py +10 -0
  6. mineflex-0.1.0/mineflex/actions/action.py +51 -0
  7. mineflex-0.1.0/mineflex/auth/__init__.py +3 -0
  8. mineflex-0.1.0/mineflex/bot.py +1011 -0
  9. mineflex-0.1.0/mineflex/chat/__init__.py +3 -0
  10. mineflex-0.1.0/mineflex/chat/message.py +105 -0
  11. mineflex-0.1.0/mineflex/client/__init__.py +16 -0
  12. mineflex-0.1.0/mineflex/client/connection.py +228 -0
  13. mineflex-0.1.0/mineflex/client/keepalive.py +72 -0
  14. mineflex-0.1.0/mineflex/client/packet_handler.py +613 -0
  15. mineflex-0.1.0/mineflex/client/protocol.py +374 -0
  16. mineflex-0.1.0/mineflex/constants.py +37 -0
  17. mineflex-0.1.0/mineflex/crafting/__init__.py +13 -0
  18. mineflex-0.1.0/mineflex/crafting/manager.py +133 -0
  19. mineflex-0.1.0/mineflex/crafting/recipe.py +127 -0
  20. mineflex-0.1.0/mineflex/data/__init__.py +3 -0
  21. mineflex-0.1.0/mineflex/entity/__init__.py +3 -0
  22. mineflex-0.1.0/mineflex/entity/entity.py +76 -0
  23. mineflex-0.1.0/mineflex/entity/player.py +36 -0
  24. mineflex-0.1.0/mineflex/entity/tracker.py +199 -0
  25. mineflex-0.1.0/mineflex/errors.py +77 -0
  26. mineflex-0.1.0/mineflex/events/__init__.py +3 -0
  27. mineflex-0.1.0/mineflex/inventory/__init__.py +16 -0
  28. mineflex-0.1.0/mineflex/inventory/inventory.py +167 -0
  29. mineflex-0.1.0/mineflex/inventory/item.py +98 -0
  30. mineflex-0.1.0/mineflex/inventory/slot.py +53 -0
  31. mineflex-0.1.0/mineflex/inventory/window.py +150 -0
  32. mineflex-0.1.0/mineflex/logging.py +43 -0
  33. mineflex-0.1.0/mineflex/physics/__init__.py +19 -0
  34. mineflex-0.1.0/mineflex/physics/aabb.py +165 -0
  35. mineflex-0.1.0/mineflex/physics/bounding_box.py +127 -0
  36. mineflex-0.1.0/mineflex/physics/collision.py +156 -0
  37. mineflex-0.1.0/mineflex/physics/engine.py +184 -0
  38. mineflex-0.1.0/mineflex/physics/movement.py +163 -0
  39. mineflex-0.1.0/mineflex/physics/vec3.py +119 -0
  40. mineflex-0.1.0/mineflex/plugins/__init__.py +10 -0
  41. mineflex-0.1.0/mineflex/plugins/manager.py +190 -0
  42. mineflex-0.1.0/mineflex/protocol/__init__.py +20 -0
  43. mineflex-0.1.0/mineflex/protocol/codecs/__init__.py +57 -0
  44. mineflex-0.1.0/mineflex/protocol/codecs/nbt.py +608 -0
  45. mineflex-0.1.0/mineflex/protocol/codecs/position.py +63 -0
  46. mineflex-0.1.0/mineflex/protocol/codecs/slot.py +65 -0
  47. mineflex-0.1.0/mineflex/protocol/codecs/string.py +48 -0
  48. mineflex-0.1.0/mineflex/protocol/codecs/varint.py +70 -0
  49. mineflex-0.1.0/mineflex/protocol/codecs/varlong.py +70 -0
  50. mineflex-0.1.0/mineflex/protocol/deserializer.py +7 -0
  51. mineflex-0.1.0/mineflex/protocol/packet.py +68 -0
  52. mineflex-0.1.0/mineflex/protocol/packets/__init__.py +3 -0
  53. mineflex-0.1.0/mineflex/protocol/packets/configuration.py +385 -0
  54. mineflex-0.1.0/mineflex/protocol/packets/handshake.py +42 -0
  55. mineflex-0.1.0/mineflex/protocol/packets/login.py +305 -0
  56. mineflex-0.1.0/mineflex/protocol/packets/play.py +1629 -0
  57. mineflex-0.1.0/mineflex/protocol/packets/status.py +88 -0
  58. mineflex-0.1.0/mineflex/protocol/serializer.py +253 -0
  59. mineflex-0.1.0/mineflex/types.py +15 -0
  60. mineflex-0.1.0/mineflex/world/__init__.py +3 -0
  61. mineflex-0.1.0/mineflex/world/biome.py +58 -0
  62. mineflex-0.1.0/mineflex/world/block.py +71 -0
  63. mineflex-0.1.0/mineflex/world/chunk.py +350 -0
  64. mineflex-0.1.0/mineflex/world/heightmap.py +90 -0
  65. mineflex-0.1.0/mineflex/world/palette.py +69 -0
  66. mineflex-0.1.0/mineflex/world/world.py +289 -0
  67. mineflex-0.1.0/mineflex.egg-info/PKG-INFO +147 -0
  68. mineflex-0.1.0/mineflex.egg-info/SOURCES.txt +85 -0
  69. mineflex-0.1.0/mineflex.egg-info/dependency_links.txt +1 -0
  70. mineflex-0.1.0/mineflex.egg-info/requires.txt +16 -0
  71. mineflex-0.1.0/mineflex.egg-info/top_level.txt +1 -0
  72. mineflex-0.1.0/pyproject.toml +96 -0
  73. mineflex-0.1.0/setup.cfg +4 -0
  74. mineflex-0.1.0/tests/test_actions.py +59 -0
  75. mineflex-0.1.0/tests/test_biome.py +58 -0
  76. mineflex-0.1.0/tests/test_bot.py +111 -0
  77. mineflex-0.1.0/tests/test_connection.py +47 -0
  78. mineflex-0.1.0/tests/test_crafting.py +189 -0
  79. mineflex-0.1.0/tests/test_entity.py +140 -0
  80. mineflex-0.1.0/tests/test_heightmap.py +68 -0
  81. mineflex-0.1.0/tests/test_inventory.py +269 -0
  82. mineflex-0.1.0/tests/test_nbt.py +298 -0
  83. mineflex-0.1.0/tests/test_physics.py +279 -0
  84. mineflex-0.1.0/tests/test_plugins.py +192 -0
  85. mineflex-0.1.0/tests/test_protocol_codecs.py +176 -0
  86. mineflex-0.1.0/tests/test_world.py +184 -0
  87. mineflex-0.1.0/tests/test_world_find.py +96 -0
mineflex-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mineflex 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.
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: mineflex
3
+ Version: 0.1.0
4
+ Summary: A native Python Minecraft bot framework inspired by Mineflayer
5
+ Author: Mineflex Contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/yourusername/mineflex
8
+ Project-URL: Documentation, https://github.com/yourusername/mineflex/docs
9
+ Project-URL: Repository, https://github.com/yourusername/mineflex
10
+ Project-URL: Issues, https://github.com/yourusername/mineflex/issues
11
+ Keywords: minecraft,bot,mineflayer,minecraft-protocol
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Games/Entertainment
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: asyncio
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0; extra == "dev"
27
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
28
+ Requires-Dist: mypy>=1.0; extra == "dev"
29
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
30
+ Requires-Dist: black>=23.0; extra == "dev"
31
+ Requires-Dist: pre-commit>=3.0; extra == "dev"
32
+ Provides-Extra: auth
33
+ Requires-Dist: msal>=1.20; extra == "auth"
34
+ Provides-Extra: test
35
+ Requires-Dist: pytest>=7.0; extra == "test"
36
+ Requires-Dist: pytest-asyncio>=0.21; extra == "test"
37
+ Dynamic: license-file
38
+
39
+ # Mineflex
40
+
41
+ A native Python implementation of a Minecraft bot framework, inspired by and behaviorally compatible with [Mineflayer](https://github.com/PrismarineJS/mineflayer).
42
+
43
+ ## Overview
44
+
45
+ Mineflex provides a Pythonic API for creating Minecraft bots with asyncio support, designed to offer the same fundamental capabilities and developer experience as Mineflayer while leveraging Python's strengths.
46
+
47
+ ## Target Usage
48
+
49
+ ```python
50
+ import asyncio
51
+ from mineflex import create_bot
52
+
53
+ async def main():
54
+ bot = create_bot(
55
+ host="localhost",
56
+ port=25565,
57
+ username="Bot",
58
+ auth="offline",
59
+ version="auto",
60
+ )
61
+
62
+ @bot.on("chat")
63
+ async def on_chat(username, message, *args):
64
+ if username != bot.username:
65
+ await bot.chat(message)
66
+
67
+ @bot.on("spawn")
68
+ async def on_spawn(*args):
69
+ print("Bot spawned:", bot.username)
70
+
71
+ await bot.run()
72
+
73
+ if __name__ == "__main__":
74
+ asyncio.run(main())
75
+ ```
76
+
77
+ ## Features
78
+
79
+ Mineflex aims to provide feature parity with Mineflayer, including:
80
+
81
+ - Minecraft protocol implementation
82
+ - Entity knowledge and tracking
83
+ - Block knowledge and world queries
84
+ - Physics and movement simulation
85
+ - Inventory management
86
+ - Crafting, chests, and containers
87
+ - Digging and building
88
+ - Health, food, and status tracking
89
+ - Chat and messaging
90
+ - Plugin system for extensibility
91
+
92
+ ## Architecture
93
+
94
+ Mineflex is designed as a modular, native Python implementation with clear separation of concerns:
95
+
96
+ - **Protocol Layer**: Minecraft protocol parsing/serialization
97
+ - **Client Layer**: Network connection and packet handling
98
+ - **World Layer**: Chunks, blocks, biomes, and spatial queries
99
+ - **Entity Layer**: Entity tracking and state management
100
+ - **Physics Layer**: Movement simulation and collision detection
101
+ - **Inventory Layer**: Items, slots, and container management
102
+ - **Actions Layer**: Digging, building, combat, and interaction
103
+ - **Chat Layer**: Message parsing and component handling
104
+ - **Authentication Layer**: Offline and Microsoft authentication
105
+ - **Plugin System**: Extensibility and lifecycle management
106
+
107
+ ## Development Status
108
+
109
+ **Current Status**: Foundation Complete (Phase 7)
110
+
111
+ Mineflex has completed its foundational implementation with 171 passing unit tests across all major subsystems:
112
+
113
+ - ✅ Protocol Layer: Codecs, packet definitions, connection handling
114
+ - ✅ Client Layer: Connection, keepalive, packet handler
115
+ - ✅ World Layer: Chunks, blocks, biomes, heightmaps, spatial queries
116
+ - ✅ Entity Layer: Entity tracking, player entities, nearest entity search
117
+ - ✅ Physics Layer: Movement simulation, collision detection, gravity
118
+ - ✅ Inventory Layer: Items, slots, windows, container management
119
+ - ✅ Crafting Layer: Recipe management, crafting feasibility checking
120
+ - ✅ Actions Layer: Action primitives (dig, build, use_item, attack)
121
+ - ✅ Plugin System: Plugin lifecycle management and extensibility
122
+ - ✅ Event System: Async event emitter with handler management
123
+
124
+ **Limitations**: This is an early implementation. Real-server integration, full protocol support, Microsoft authentication, and many Mineflayer features are not yet implemented. See [docs/COMPATIBILITY_REPORT.md](docs/COMPATIBILITY_REPORT.md) for detailed status.
125
+
126
+ ## Installation
127
+
128
+ ```bash
129
+ pip install mineflex
130
+ ```
131
+
132
+ ## Documentation
133
+
134
+ - [Getting Started](docs/getting_started.md)
135
+ - [Architecture](docs/architecture.md)
136
+ - [API Reference](docs/api.md)
137
+ - [Plugin Development](docs/plugins.md)
138
+ - [Authentication](docs/authentication.md)
139
+ - [Version Support](docs/version_support.md)
140
+
141
+ ## License
142
+
143
+ MIT License - See [LICENSE](LICENSE) file
144
+
145
+ ## Acknowledgments
146
+
147
+ Mineflex is inspired by and aims for behavioral compatibility with [Mineflayer](https://github.com/PrismarineJS/mineflayer) and the [PrismarineJS](https://github.com/PrismarineJS) ecosystem. This is an independent Python implementation, not a translation or wrapper.
@@ -0,0 +1,109 @@
1
+ # Mineflex
2
+
3
+ A native Python implementation of a Minecraft bot framework, inspired by and behaviorally compatible with [Mineflayer](https://github.com/PrismarineJS/mineflayer).
4
+
5
+ ## Overview
6
+
7
+ Mineflex provides a Pythonic API for creating Minecraft bots with asyncio support, designed to offer the same fundamental capabilities and developer experience as Mineflayer while leveraging Python's strengths.
8
+
9
+ ## Target Usage
10
+
11
+ ```python
12
+ import asyncio
13
+ from mineflex import create_bot
14
+
15
+ async def main():
16
+ bot = create_bot(
17
+ host="localhost",
18
+ port=25565,
19
+ username="Bot",
20
+ auth="offline",
21
+ version="auto",
22
+ )
23
+
24
+ @bot.on("chat")
25
+ async def on_chat(username, message, *args):
26
+ if username != bot.username:
27
+ await bot.chat(message)
28
+
29
+ @bot.on("spawn")
30
+ async def on_spawn(*args):
31
+ print("Bot spawned:", bot.username)
32
+
33
+ await bot.run()
34
+
35
+ if __name__ == "__main__":
36
+ asyncio.run(main())
37
+ ```
38
+
39
+ ## Features
40
+
41
+ Mineflex aims to provide feature parity with Mineflayer, including:
42
+
43
+ - Minecraft protocol implementation
44
+ - Entity knowledge and tracking
45
+ - Block knowledge and world queries
46
+ - Physics and movement simulation
47
+ - Inventory management
48
+ - Crafting, chests, and containers
49
+ - Digging and building
50
+ - Health, food, and status tracking
51
+ - Chat and messaging
52
+ - Plugin system for extensibility
53
+
54
+ ## Architecture
55
+
56
+ Mineflex is designed as a modular, native Python implementation with clear separation of concerns:
57
+
58
+ - **Protocol Layer**: Minecraft protocol parsing/serialization
59
+ - **Client Layer**: Network connection and packet handling
60
+ - **World Layer**: Chunks, blocks, biomes, and spatial queries
61
+ - **Entity Layer**: Entity tracking and state management
62
+ - **Physics Layer**: Movement simulation and collision detection
63
+ - **Inventory Layer**: Items, slots, and container management
64
+ - **Actions Layer**: Digging, building, combat, and interaction
65
+ - **Chat Layer**: Message parsing and component handling
66
+ - **Authentication Layer**: Offline and Microsoft authentication
67
+ - **Plugin System**: Extensibility and lifecycle management
68
+
69
+ ## Development Status
70
+
71
+ **Current Status**: Foundation Complete (Phase 7)
72
+
73
+ Mineflex has completed its foundational implementation with 171 passing unit tests across all major subsystems:
74
+
75
+ - ✅ Protocol Layer: Codecs, packet definitions, connection handling
76
+ - ✅ Client Layer: Connection, keepalive, packet handler
77
+ - ✅ World Layer: Chunks, blocks, biomes, heightmaps, spatial queries
78
+ - ✅ Entity Layer: Entity tracking, player entities, nearest entity search
79
+ - ✅ Physics Layer: Movement simulation, collision detection, gravity
80
+ - ✅ Inventory Layer: Items, slots, windows, container management
81
+ - ✅ Crafting Layer: Recipe management, crafting feasibility checking
82
+ - ✅ Actions Layer: Action primitives (dig, build, use_item, attack)
83
+ - ✅ Plugin System: Plugin lifecycle management and extensibility
84
+ - ✅ Event System: Async event emitter with handler management
85
+
86
+ **Limitations**: This is an early implementation. Real-server integration, full protocol support, Microsoft authentication, and many Mineflayer features are not yet implemented. See [docs/COMPATIBILITY_REPORT.md](docs/COMPATIBILITY_REPORT.md) for detailed status.
87
+
88
+ ## Installation
89
+
90
+ ```bash
91
+ pip install mineflex
92
+ ```
93
+
94
+ ## Documentation
95
+
96
+ - [Getting Started](docs/getting_started.md)
97
+ - [Architecture](docs/architecture.md)
98
+ - [API Reference](docs/api.md)
99
+ - [Plugin Development](docs/plugins.md)
100
+ - [Authentication](docs/authentication.md)
101
+ - [Version Support](docs/version_support.md)
102
+
103
+ ## License
104
+
105
+ MIT License - See [LICENSE](LICENSE) file
106
+
107
+ ## Acknowledgments
108
+
109
+ Mineflex is inspired by and aims for behavioral compatibility with [Mineflayer](https://github.com/PrismarineJS/mineflayer) and the [PrismarineJS](https://github.com/PrismarineJS) ecosystem. This is an independent Python implementation, not a translation or wrapper.
@@ -0,0 +1,48 @@
1
+ """
2
+ Mineflex - A native Python Minecraft bot framework.
3
+
4
+ This package provides a Pythonic API for creating Minecraft bots
5
+ with asyncio support, inspired by Mineflayer.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ __version__ = "0.1.0"
11
+
12
+ # Public API
13
+ from mineflex.bot import Bot, create_bot
14
+ from mineflex.errors import (
15
+ MineflexError,
16
+ ConnectionError,
17
+ AuthenticationError,
18
+ ProtocolError,
19
+ PacketError,
20
+ UnsupportedVersionError,
21
+ TimeoutError,
22
+ InvalidStateError,
23
+ InteractionError,
24
+ DiggingError,
25
+ InventoryError,
26
+ CraftingError,
27
+ )
28
+
29
+ __all__ = [
30
+ # Version
31
+ "__version__",
32
+ # Main API
33
+ "Bot",
34
+ "create_bot",
35
+ # Exceptions
36
+ "MineflexError",
37
+ "ConnectionError",
38
+ "AuthenticationError",
39
+ "ProtocolError",
40
+ "PacketError",
41
+ "UnsupportedVersionError",
42
+ "TimeoutError",
43
+ "InvalidStateError",
44
+ "InteractionError",
45
+ "DiggingError",
46
+ "InventoryError",
47
+ "CraftingError",
48
+ ]
@@ -0,0 +1,10 @@
1
+ """Actions subsystem - digging, building, combat."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from mineflex.actions.action import Action, ActionType
6
+
7
+ __all__ = [
8
+ "Action",
9
+ "ActionType",
10
+ ]
@@ -0,0 +1,51 @@
1
+ """Interaction actions (digging, building, item use)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from enum import Enum
7
+ from typing import Optional
8
+
9
+ from mineflex.physics.vec3 import Vec3
10
+
11
+
12
+ class ActionType(Enum):
13
+ """Types of actions."""
14
+
15
+ DIG = "dig"
16
+ BUILD = "build"
17
+ USE_ITEM = "use_item"
18
+ ATTACK = "attack"
19
+ INTERACT = "interact"
20
+
21
+
22
+ @dataclass
23
+ class Action:
24
+ """
25
+ Represents an action to perform on a block or entity.
26
+ """
27
+
28
+ action_type: ActionType
29
+ position: Vec3
30
+ face: Optional[int] = None # Block face (0-5) for building
31
+ block_id: Optional[int] = None # Block ID for building
32
+
33
+ @classmethod
34
+ def dig(cls, position: Vec3) -> "Action":
35
+ """Create a dig action."""
36
+ return cls(ActionType.DIG, position)
37
+
38
+ @classmethod
39
+ def build(cls, position: Vec3, block_id: int, face: int) -> "Action":
40
+ """Create a build action."""
41
+ return cls(ActionType.BUILD, position, face, block_id)
42
+
43
+ @classmethod
44
+ def use_item(cls, position: Vec3) -> "Action":
45
+ """Create a use item action."""
46
+ return cls(ActionType.USE_ITEM, position)
47
+
48
+ @classmethod
49
+ def attack(cls, position: Vec3) -> "Action":
50
+ """Create an attack action."""
51
+ return cls(ActionType.ATTACK, position)
@@ -0,0 +1,3 @@
1
+ """Authentication subsystem - offline and Microsoft auth."""
2
+
3
+ from __future__ import annotations