mcapibridge 0.1.1__tar.gz → 0.1.3__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.
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/PKG-INFO +22 -4
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/README.MD +266 -248
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/pyproject.toml +1 -1
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/src/mc/minecraft.py +15 -2
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/src/mcapibridge.egg-info/PKG-INFO +22 -4
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/LICENSE +0 -0
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/setup.cfg +0 -0
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/src/mc/__init__.py +0 -0
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/src/mcapibridge.egg-info/SOURCES.txt +0 -0
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/src/mcapibridge.egg-info/dependency_links.txt +0 -0
- {mcapibridge-0.1.1 → mcapibridge-0.1.3}/src/mcapibridge.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcapibridge
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Python libary for MCAPIBridge
|
|
5
5
|
Author: TaotianZhufang
|
|
6
6
|
License: MIT License
|
|
@@ -127,13 +127,31 @@ Sets the text on a sign block.
|
|
|
127
127
|
|
|
128
128
|
**The block at the position must already be a sign.**
|
|
129
129
|
|
|
130
|
+
#### `lookAt(target, x, y, z)`
|
|
131
|
+
Forces a player or entity to look at a specific coordinate.
|
|
132
|
+
* **target**: String player name or Entity ID.
|
|
133
|
+
* **x, y, z**: The coordinate to look at.
|
|
134
|
+
* *Example*: `mc.lookAt("Steve", 0, 100, 0)` forces Steve to look up.
|
|
135
|
+
|
|
136
|
+
#### `setEntityNbt(entity_id, nbt_string)`
|
|
137
|
+
Modifies the NBT data of an entity directly using JSON format.
|
|
138
|
+
* **entity_id**: Integer Entity ID.
|
|
139
|
+
* **nbt_string**: Valid SNBT string (e.g., `"{NoAI:1b, Glowing:1b}"`).
|
|
140
|
+
* *Note*: Useful for setting attributes like Scale in 1.20.6 (`{Attributes:[{Name:"generic.scale",Base:2.0d}]}`).
|
|
141
|
+
|
|
142
|
+
#### `setBlockNbt(x, y, z, nbt_string, dimension=None)`
|
|
143
|
+
Modifies the NBT data of a block entity (Tile Entity).
|
|
144
|
+
* **x, y, z**: Integer coordinates.
|
|
145
|
+
* **nbt_string**: Valid SNBT string.
|
|
146
|
+
|
|
147
|
+
|
|
130
148
|
---
|
|
131
149
|
|
|
132
150
|
### Info
|
|
133
151
|
|
|
134
152
|
#### `getOnlinePlayers()`
|
|
135
153
|
Get players' name online.
|
|
136
|
-
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]
|
|
154
|
+
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]`.
|
|
137
155
|
|
|
138
156
|
#### `getPlayerPos(target="")`
|
|
139
157
|
Get player's position and yaw and pitch.
|
|
@@ -245,7 +263,7 @@ Get click events.
|
|
|
245
263
|
* Double z
|
|
246
264
|
* **face**: Int click face.
|
|
247
265
|
* **entityId**: Int ID of clicking on entity.
|
|
248
|
-
* **action**: Int action type:1--left click,2--right click.(
|
|
266
|
+
* **action**: Int action type:1--left click,2--right click,101-105--Keyboard pressed.(Bind keys at Minecraft settings)
|
|
249
267
|
* **type**: String action:"LEFT_CLICK" or "RIGHT_CLICK"
|
|
250
268
|
|
|
251
269
|
#### `pollChatPosts()`
|
|
@@ -274,7 +292,7 @@ Represents a 3D vector/coordinate.
|
|
|
274
292
|
* **length()**: Returns vector length.
|
|
275
293
|
|
|
276
294
|
#### `PlayerPos`
|
|
277
|
-
**Inherits Vec3
|
|
295
|
+
**Inherits Vec3** Represents player position with rotation.
|
|
278
296
|
* **properties**: `x`,`y`,`z`,`yaw`,`pitch`.
|
|
279
297
|
* **Methods**:
|
|
280
298
|
* **forward(distance=1.0)**: Returns a new `Vec3` position at `distance` blocks ahead of the player's view.
|
|
@@ -1,248 +1,266 @@
|
|
|
1
|
-
# MCAPIBridge Python Libary
|
|
2
|
-
|
|
3
|
-
MCAPIBridge is a mod for Minecraft loaded with Fabric.This libary offers some ways to connect Minecraft with this mod in Python.
|
|
4
|
-
|
|
5
|
-
## QuickStart
|
|
6
|
-
|
|
7
|
-
### Install
|
|
8
|
-
Ensure your mod loaded.
|
|
9
|
-
|
|
10
|
-
Use pip to install this.
|
|
11
|
-
```
|
|
12
|
-
pip install mcapibridge
|
|
13
|
-
```
|
|
14
|
-
This is a simple example to connect.
|
|
15
|
-
```
|
|
16
|
-
from mc import Minecraft
|
|
17
|
-
import time
|
|
18
|
-
|
|
19
|
-
# Default ip is localhost and port is 4711
|
|
20
|
-
# You can use mc = Minecraft(host=YOURIP,port=YOURPORT) to change
|
|
21
|
-
mc = Minecraft()
|
|
22
|
-
|
|
23
|
-
# Show a message
|
|
24
|
-
mc.postToChat("§aHello, Minecraft! Python is here.")
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## Usage
|
|
30
|
-
|
|
31
|
-
### Basic
|
|
32
|
-
|
|
33
|
-
#### `postToChat(msg)`
|
|
34
|
-
Send a message to chat screen.
|
|
35
|
-
* **msg**: String message.Support `§` .You can check it on Minecraft wiki.
|
|
36
|
-
|
|
37
|
-
#### `runCommand(cmd)`
|
|
38
|
-
Run commands as Server.
|
|
39
|
-
* **cmd**: Srting command without '/'
|
|
40
|
-
|
|
41
|
-
Ex: `mc.runCommand("time set day")`
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
### World
|
|
46
|
-
|
|
47
|
-
#### `setBlock(x, y, z, block_id, dimension=None)`
|
|
48
|
-
Set a block at the point given.
|
|
49
|
-
* **x, y, z**: Int positions.
|
|
50
|
-
* **block_id**: String ID.If it is Minecraft vanilla,the ID can be written without `Minecraft:`. Ex:`"stone"`, `"diamond_block"`.Support other namespaces.
|
|
51
|
-
* **dimension**: Optional String target dimension/player name.
|
|
52
|
-
|
|
53
|
-
#### `getBlock(x, y, z, dimension=None)`
|
|
54
|
-
Gets the block ID at the specified coordinates.
|
|
55
|
-
* **x, y, z**: Int positions.
|
|
56
|
-
* **dimension**: Optional String target dimension/player name.
|
|
57
|
-
* **return**: String block ID.Ex.`"minecraft:grass_block"`.
|
|
58
|
-
|
|
59
|
-
#### `spawnEntity(x, y, z, entity_id, yaw=0.0, pitch=0.0, dimension=None)`
|
|
60
|
-
Spawn an entity at the point given.
|
|
61
|
-
* **entity_id**: String ID.If it is Minecraft vanilla,the ID can be written without `Minecraft:`. Ex:`"zombie"`, `"pig"`, `"lightning_bolt"`.Support other namespaces.
|
|
62
|
-
* **yaw**: Optional Int degree.Horizontal degree.
|
|
63
|
-
* **pitch**: Optional Int degree.Vertical degree.
|
|
64
|
-
* **dimension**: Optional String target dimension/player name.
|
|
65
|
-
|
|
66
|
-
#### `setEntityVelocity(entity_id, vx, vy, vz)`
|
|
67
|
-
Sets the velocity of an entity.
|
|
68
|
-
* **entity_id**: Int ID.
|
|
69
|
-
* **vx, vy, vz**: Double velocity components.
|
|
70
|
-
|
|
71
|
-
#### `setEntityNoGravity(entity_id, enable=True)`
|
|
72
|
-
Enables or disables gravity for an entity.
|
|
73
|
-
* **entity_id**: Int ID.
|
|
74
|
-
|
|
75
|
-
#### `getEntities(x, y, z, radius=10, dimension=None)`
|
|
76
|
-
Gets the block ID at the specified coordinates.
|
|
77
|
-
* **x, y, z**: Double positions.
|
|
78
|
-
* **radius**: Double search radius.
|
|
79
|
-
* **dimension**: Optional String target dimension/player name.
|
|
80
|
-
* **return**: List of Dicts: [{'id': 123, 'type': 'minecraft:zombie', 'pos': Vec3}, ...]
|
|
81
|
-
|
|
82
|
-
#### `spawnParticle(x, y, z, particle_id, count=10, dx=0.0, dy=0.0, dz=0.0, speed=0.0, dimension=None)`
|
|
83
|
-
Spawn particle at the point given.
|
|
84
|
-
* **particle_id**: String ID.If it is Minecraft vanilla,the ID can be written without `Minecraft:`. Ex:`"flame"`, `"heart"`.Support other namespaces.
|
|
85
|
-
* **count**: Int count.
|
|
86
|
-
* **dx, dy, dz**: Optional double diffusion ranges.(when count=0, it represents the direction vector)
|
|
87
|
-
* **speed**: Optional double speed.
|
|
88
|
-
* **dimension**: Optional String target dimension/player name.
|
|
89
|
-
|
|
90
|
-
#### `setSign(x, y, z, line1="", line2="", line3="", line4="", dimension=None)`
|
|
91
|
-
Sets the text on a sign block.
|
|
92
|
-
* **x, y, z**: Int positions.
|
|
93
|
-
* **line1-4**: String text for each line.
|
|
94
|
-
* **dimension**: Optional String target dimension/player name.
|
|
95
|
-
|
|
96
|
-
**The block at the position must already be a sign.**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* **
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
* **
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
*
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
* **
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
#### `
|
|
177
|
-
|
|
178
|
-
* **
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
* **
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
* **
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
###
|
|
193
|
-
|
|
194
|
-
#### `
|
|
195
|
-
|
|
196
|
-
* **
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
* **
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
1
|
+
# MCAPIBridge Python Libary
|
|
2
|
+
|
|
3
|
+
MCAPIBridge is a mod for Minecraft loaded with Fabric.This libary offers some ways to connect Minecraft with this mod in Python.
|
|
4
|
+
|
|
5
|
+
## QuickStart
|
|
6
|
+
|
|
7
|
+
### Install
|
|
8
|
+
Ensure your mod loaded.
|
|
9
|
+
|
|
10
|
+
Use pip to install this.
|
|
11
|
+
```
|
|
12
|
+
pip install mcapibridge
|
|
13
|
+
```
|
|
14
|
+
This is a simple example to connect.
|
|
15
|
+
```
|
|
16
|
+
from mc import Minecraft
|
|
17
|
+
import time
|
|
18
|
+
|
|
19
|
+
# Default ip is localhost and port is 4711
|
|
20
|
+
# You can use mc = Minecraft(host=YOURIP,port=YOURPORT) to change
|
|
21
|
+
mc = Minecraft()
|
|
22
|
+
|
|
23
|
+
# Show a message
|
|
24
|
+
mc.postToChat("§aHello, Minecraft! Python is here.")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Basic
|
|
32
|
+
|
|
33
|
+
#### `postToChat(msg)`
|
|
34
|
+
Send a message to chat screen.
|
|
35
|
+
* **msg**: String message.Support `§` .You can check it on Minecraft wiki.
|
|
36
|
+
|
|
37
|
+
#### `runCommand(cmd)`
|
|
38
|
+
Run commands as Server.
|
|
39
|
+
* **cmd**: Srting command without '/'
|
|
40
|
+
|
|
41
|
+
Ex: `mc.runCommand("time set day")`
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### World
|
|
46
|
+
|
|
47
|
+
#### `setBlock(x, y, z, block_id, dimension=None)`
|
|
48
|
+
Set a block at the point given.
|
|
49
|
+
* **x, y, z**: Int positions.
|
|
50
|
+
* **block_id**: String ID.If it is Minecraft vanilla,the ID can be written without `Minecraft:`. Ex:`"stone"`, `"diamond_block"`.Support other namespaces.
|
|
51
|
+
* **dimension**: Optional String target dimension/player name.
|
|
52
|
+
|
|
53
|
+
#### `getBlock(x, y, z, dimension=None)`
|
|
54
|
+
Gets the block ID at the specified coordinates.
|
|
55
|
+
* **x, y, z**: Int positions.
|
|
56
|
+
* **dimension**: Optional String target dimension/player name.
|
|
57
|
+
* **return**: String block ID.Ex.`"minecraft:grass_block"`.
|
|
58
|
+
|
|
59
|
+
#### `spawnEntity(x, y, z, entity_id, yaw=0.0, pitch=0.0, dimension=None)`
|
|
60
|
+
Spawn an entity at the point given.
|
|
61
|
+
* **entity_id**: String ID.If it is Minecraft vanilla,the ID can be written without `Minecraft:`. Ex:`"zombie"`, `"pig"`, `"lightning_bolt"`.Support other namespaces.
|
|
62
|
+
* **yaw**: Optional Int degree.Horizontal degree.
|
|
63
|
+
* **pitch**: Optional Int degree.Vertical degree.
|
|
64
|
+
* **dimension**: Optional String target dimension/player name.
|
|
65
|
+
|
|
66
|
+
#### `setEntityVelocity(entity_id, vx, vy, vz)`
|
|
67
|
+
Sets the velocity of an entity.
|
|
68
|
+
* **entity_id**: Int ID.
|
|
69
|
+
* **vx, vy, vz**: Double velocity components.
|
|
70
|
+
|
|
71
|
+
#### `setEntityNoGravity(entity_id, enable=True)`
|
|
72
|
+
Enables or disables gravity for an entity.
|
|
73
|
+
* **entity_id**: Int ID.
|
|
74
|
+
|
|
75
|
+
#### `getEntities(x, y, z, radius=10, dimension=None)`
|
|
76
|
+
Gets the block ID at the specified coordinates.
|
|
77
|
+
* **x, y, z**: Double positions.
|
|
78
|
+
* **radius**: Double search radius.
|
|
79
|
+
* **dimension**: Optional String target dimension/player name.
|
|
80
|
+
* **return**: List of Dicts: [{'id': 123, 'type': 'minecraft:zombie', 'pos': Vec3}, ...]
|
|
81
|
+
|
|
82
|
+
#### `spawnParticle(x, y, z, particle_id, count=10, dx=0.0, dy=0.0, dz=0.0, speed=0.0, dimension=None)`
|
|
83
|
+
Spawn particle at the point given.
|
|
84
|
+
* **particle_id**: String ID.If it is Minecraft vanilla,the ID can be written without `Minecraft:`. Ex:`"flame"`, `"heart"`.Support other namespaces.
|
|
85
|
+
* **count**: Int count.
|
|
86
|
+
* **dx, dy, dz**: Optional double diffusion ranges.(when count=0, it represents the direction vector)
|
|
87
|
+
* **speed**: Optional double speed.
|
|
88
|
+
* **dimension**: Optional String target dimension/player name.
|
|
89
|
+
|
|
90
|
+
#### `setSign(x, y, z, line1="", line2="", line3="", line4="", dimension=None)`
|
|
91
|
+
Sets the text on a sign block.
|
|
92
|
+
* **x, y, z**: Int positions.
|
|
93
|
+
* **line1-4**: String text for each line.
|
|
94
|
+
* **dimension**: Optional String target dimension/player name.
|
|
95
|
+
|
|
96
|
+
**The block at the position must already be a sign.**
|
|
97
|
+
|
|
98
|
+
#### `lookAt(target, x, y, z)`
|
|
99
|
+
Forces a player or entity to look at a specific coordinate.
|
|
100
|
+
* **target**: String player name or Entity ID.
|
|
101
|
+
* **x, y, z**: The coordinate to look at.
|
|
102
|
+
* *Example*: `mc.lookAt("Steve", 0, 100, 0)` forces Steve to look up.
|
|
103
|
+
|
|
104
|
+
#### `setEntityNbt(entity_id, nbt_string)`
|
|
105
|
+
Modifies the NBT data of an entity directly using JSON format.
|
|
106
|
+
* **entity_id**: Integer Entity ID.
|
|
107
|
+
* **nbt_string**: Valid SNBT string (e.g., `"{NoAI:1b, Glowing:1b}"`).
|
|
108
|
+
* *Note*: Useful for setting attributes like Scale in 1.20.6 (`{Attributes:[{Name:"generic.scale",Base:2.0d}]}`).
|
|
109
|
+
|
|
110
|
+
#### `setBlockNbt(x, y, z, nbt_string, dimension=None)`
|
|
111
|
+
Modifies the NBT data of a block entity (Tile Entity).
|
|
112
|
+
* **x, y, z**: Integer coordinates.
|
|
113
|
+
* **nbt_string**: Valid SNBT string.
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### Info
|
|
119
|
+
|
|
120
|
+
#### `getOnlinePlayers()`
|
|
121
|
+
Get players' name online.
|
|
122
|
+
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]`.
|
|
123
|
+
|
|
124
|
+
#### `getPlayerPos(target="")`
|
|
125
|
+
Get player's position and yaw and pitch.
|
|
126
|
+
* **target**: String player name.
|
|
127
|
+
* **return**: Int x,y,z and Double yaw,pitch.
|
|
128
|
+
|
|
129
|
+
#### `getPlayerEntityId(name)`
|
|
130
|
+
Get player's ID.
|
|
131
|
+
* **name**: String player name.
|
|
132
|
+
* **return**: Int ID.
|
|
133
|
+
|
|
134
|
+
#### `getPlayerName(entity_id)`
|
|
135
|
+
Get player's ID.
|
|
136
|
+
* **entity_id**: Int ID.
|
|
137
|
+
* **return**: String player name.
|
|
138
|
+
|
|
139
|
+
#### `getPlayerDetails(target="")`
|
|
140
|
+
Get player's details.
|
|
141
|
+
* **target**: String player name.
|
|
142
|
+
* **return**: Dict including
|
|
143
|
+
* `name`: String player name
|
|
144
|
+
* `id`: Int ID
|
|
145
|
+
* `mode`: String gamemode
|
|
146
|
+
* `health`: Double health
|
|
147
|
+
* `max_health`: Double max health
|
|
148
|
+
* `food`: Int food
|
|
149
|
+
* `held_item`: String item held
|
|
150
|
+
* `held_count`: Int item held count
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
### State
|
|
155
|
+
|
|
156
|
+
#### `setHealth(target, amount)`
|
|
157
|
+
Set player's health.
|
|
158
|
+
* **target**: String player name.
|
|
159
|
+
* **amount**: Double health.
|
|
160
|
+
|
|
161
|
+
#### `setFood(target, amount)`
|
|
162
|
+
Set player's food.
|
|
163
|
+
* **target**: String player name.
|
|
164
|
+
* **amount**: Int food(0-20).
|
|
165
|
+
|
|
166
|
+
#### `giveEffect(target, effect_name, duration_sec=30, amplifier=1)`
|
|
167
|
+
Effect player.
|
|
168
|
+
* **effect_name**: String effect ID.Ex:`"speed"`,`"night_vision"`.
|
|
169
|
+
* **duration_sec**: Int seconds.
|
|
170
|
+
* **amplifier**: Int amplifier.
|
|
171
|
+
|
|
172
|
+
#### `setFlying(target, allow_flight=True, is_flying=True)`
|
|
173
|
+
Enable player to fly in survival mode.
|
|
174
|
+
* **target**: String player name.
|
|
175
|
+
|
|
176
|
+
#### `setFlySpeed(target, speed=0.05)`
|
|
177
|
+
Set flight speed.
|
|
178
|
+
* **target**: String player name.
|
|
179
|
+
* **speed**: Double speed.Default 0.05.
|
|
180
|
+
|
|
181
|
+
#### `setWalkSpeed(target, speed=0.1)`
|
|
182
|
+
Set walk speed.
|
|
183
|
+
* **target**: String player name.
|
|
184
|
+
* **speed**: Double speed.Default 0.1.
|
|
185
|
+
|
|
186
|
+
#### `setGodMode(target, enable=True)`
|
|
187
|
+
Enable invulnerability.
|
|
188
|
+
* **target**: String player name.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### Inventory
|
|
193
|
+
|
|
194
|
+
#### `getInventory(target="")`
|
|
195
|
+
Get player's inventory.
|
|
196
|
+
* **return**: List of Dicts.Every dict has `{'slot': block_ID, 'id': item_ID, 'count': item_count}`.
|
|
197
|
+
|
|
198
|
+
#### `give(target, item_id, count=1)`
|
|
199
|
+
Give player item.
|
|
200
|
+
* **item_id**: String item ID.
|
|
201
|
+
* **count**: Int count.
|
|
202
|
+
|
|
203
|
+
#### `clearInventory(target, item_id="")`
|
|
204
|
+
Clear inventory.
|
|
205
|
+
* **target**: String player name.
|
|
206
|
+
* **item_id**: String item ID.
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
### TP
|
|
211
|
+
|
|
212
|
+
#### `teleport(x, y, z, target="")`
|
|
213
|
+
TP player.
|
|
214
|
+
* **x, y, z**: Int target x,y,z.
|
|
215
|
+
* **target**: String player ID.
|
|
216
|
+
|
|
217
|
+
#### `teleportEntity(entity_id, x, y, z)`
|
|
218
|
+
TP entitie.
|
|
219
|
+
* **entity_id**: Int entity id.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
### Events
|
|
224
|
+
|
|
225
|
+
#### `pollBlockHits()`
|
|
226
|
+
Get click events.
|
|
227
|
+
* **return**: List Class `[BlockHit1,BlockHit2,.....]`
|
|
228
|
+
* **pos**: Class Vec3
|
|
229
|
+
* Double x
|
|
230
|
+
* Double y
|
|
231
|
+
* Double z
|
|
232
|
+
* **face**: Int click face.
|
|
233
|
+
* **entityId**: Int ID of clicking on entity.
|
|
234
|
+
* **action**: Int action type:1--left click,2--right click,101-105--Keyboard pressed.(Bind keys at Minecraft settings)
|
|
235
|
+
* **type**: String action:"LEFT_CLICK" or "RIGHT_CLICK"
|
|
236
|
+
|
|
237
|
+
#### `pollChatPosts()`
|
|
238
|
+
Get player message events.
|
|
239
|
+
* **return**: List Class `[ChatPost1,ChatPost2,.....]`
|
|
240
|
+
* **name**: String player name.
|
|
241
|
+
* **message**: String message.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
### Helper Methods
|
|
246
|
+
|
|
247
|
+
#### `getDirectionVector(target="")`
|
|
248
|
+
Calculates the direction vector based on a player's rotation. Useful for shooting projectiles.
|
|
249
|
+
* **target**: String player ID.
|
|
250
|
+
* **return**: Class `Vec3` normalized direction vector.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
### Helper Classes
|
|
255
|
+
|
|
256
|
+
#### `Vec3`
|
|
257
|
+
Represents a 3D vector/coordinate.
|
|
258
|
+
* **properties**: `x`,`y`,`z`.
|
|
259
|
+
* **Methods**:
|
|
260
|
+
* **length()**: Returns vector length.
|
|
261
|
+
|
|
262
|
+
#### `PlayerPos`
|
|
263
|
+
**Inherits Vec3** Represents player position with rotation.
|
|
264
|
+
* **properties**: `x`,`y`,`z`,`yaw`,`pitch`.
|
|
265
|
+
* **Methods**:
|
|
266
|
+
* **forward(distance=1.0)**: Returns a new `Vec3` position at `distance` blocks ahead of the player's view.
|
|
@@ -41,8 +41,10 @@ class BlockHit:
|
|
|
41
41
|
self.pos = Vec3(x, y, z)
|
|
42
42
|
self.face = face
|
|
43
43
|
self.entityId = entityId
|
|
44
|
-
self.action = action # 1=Left,2=Right
|
|
45
|
-
|
|
44
|
+
self.action = action # 1=Left,2=Right,101-105:Keyboard Action
|
|
45
|
+
if action == 1: self.type = "LEFT_CLICK"
|
|
46
|
+
elif action == 2: self.type = "RIGHT_CLICK"
|
|
47
|
+
elif action > 100: self.type = f"KEY_MACRO_{action - 100}"
|
|
46
48
|
|
|
47
49
|
class Minecraft:
|
|
48
50
|
def __init__(self, host="localhost", port=4711):
|
|
@@ -340,3 +342,14 @@ class Minecraft:
|
|
|
340
342
|
cmd = f"world.setSign({int(x)},{int(y)},{int(z)},{l1},{l2},{l3},{l4})"
|
|
341
343
|
if dimension: cmd += f",{dimension}"
|
|
342
344
|
self._send(cmd)
|
|
345
|
+
|
|
346
|
+
def lookAt(self, target, x, y, z):
|
|
347
|
+
self._send(f"player.lookAt({target},{x},{y},{z})")
|
|
348
|
+
|
|
349
|
+
def setEntityNbt(self, entity_id, nbt_string):
|
|
350
|
+
self._send(f"entity.setNbt({entity_id},{nbt_string})")
|
|
351
|
+
|
|
352
|
+
def setBlockNbt(self, x, y, z, nbt_string, dimension=None):
|
|
353
|
+
cmd = f"block.setNbt({int(x)},{int(y)},{int(z)},{nbt_string})"
|
|
354
|
+
if dimension: cmd += f",{dimension}"
|
|
355
|
+
self._send(cmd)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcapibridge
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Python libary for MCAPIBridge
|
|
5
5
|
Author: TaotianZhufang
|
|
6
6
|
License: MIT License
|
|
@@ -127,13 +127,31 @@ Sets the text on a sign block.
|
|
|
127
127
|
|
|
128
128
|
**The block at the position must already be a sign.**
|
|
129
129
|
|
|
130
|
+
#### `lookAt(target, x, y, z)`
|
|
131
|
+
Forces a player or entity to look at a specific coordinate.
|
|
132
|
+
* **target**: String player name or Entity ID.
|
|
133
|
+
* **x, y, z**: The coordinate to look at.
|
|
134
|
+
* *Example*: `mc.lookAt("Steve", 0, 100, 0)` forces Steve to look up.
|
|
135
|
+
|
|
136
|
+
#### `setEntityNbt(entity_id, nbt_string)`
|
|
137
|
+
Modifies the NBT data of an entity directly using JSON format.
|
|
138
|
+
* **entity_id**: Integer Entity ID.
|
|
139
|
+
* **nbt_string**: Valid SNBT string (e.g., `"{NoAI:1b, Glowing:1b}"`).
|
|
140
|
+
* *Note*: Useful for setting attributes like Scale in 1.20.6 (`{Attributes:[{Name:"generic.scale",Base:2.0d}]}`).
|
|
141
|
+
|
|
142
|
+
#### `setBlockNbt(x, y, z, nbt_string, dimension=None)`
|
|
143
|
+
Modifies the NBT data of a block entity (Tile Entity).
|
|
144
|
+
* **x, y, z**: Integer coordinates.
|
|
145
|
+
* **nbt_string**: Valid SNBT string.
|
|
146
|
+
|
|
147
|
+
|
|
130
148
|
---
|
|
131
149
|
|
|
132
150
|
### Info
|
|
133
151
|
|
|
134
152
|
#### `getOnlinePlayers()`
|
|
135
153
|
Get players' name online.
|
|
136
|
-
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]
|
|
154
|
+
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]`.
|
|
137
155
|
|
|
138
156
|
#### `getPlayerPos(target="")`
|
|
139
157
|
Get player's position and yaw and pitch.
|
|
@@ -245,7 +263,7 @@ Get click events.
|
|
|
245
263
|
* Double z
|
|
246
264
|
* **face**: Int click face.
|
|
247
265
|
* **entityId**: Int ID of clicking on entity.
|
|
248
|
-
* **action**: Int action type:1--left click,2--right click.(
|
|
266
|
+
* **action**: Int action type:1--left click,2--right click,101-105--Keyboard pressed.(Bind keys at Minecraft settings)
|
|
249
267
|
* **type**: String action:"LEFT_CLICK" or "RIGHT_CLICK"
|
|
250
268
|
|
|
251
269
|
#### `pollChatPosts()`
|
|
@@ -274,7 +292,7 @@ Represents a 3D vector/coordinate.
|
|
|
274
292
|
* **length()**: Returns vector length.
|
|
275
293
|
|
|
276
294
|
#### `PlayerPos`
|
|
277
|
-
**Inherits Vec3
|
|
295
|
+
**Inherits Vec3** Represents player position with rotation.
|
|
278
296
|
* **properties**: `x`,`y`,`z`,`yaw`,`pitch`.
|
|
279
297
|
* **Methods**:
|
|
280
298
|
* **forward(distance=1.0)**: Returns a new `Vec3` position at `distance` blocks ahead of the player's view.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|