mcapibridge 0.1.1__tar.gz → 0.1.2__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.2}/PKG-INFO +4 -4
- {mcapibridge-0.1.1 → mcapibridge-0.1.2}/README.MD +248 -248
- {mcapibridge-0.1.1 → mcapibridge-0.1.2}/pyproject.toml +1 -1
- {mcapibridge-0.1.1 → mcapibridge-0.1.2}/src/mc/minecraft.py +4 -2
- {mcapibridge-0.1.1 → mcapibridge-0.1.2}/src/mcapibridge.egg-info/PKG-INFO +4 -4
- {mcapibridge-0.1.1 → mcapibridge-0.1.2}/LICENSE +0 -0
- {mcapibridge-0.1.1 → mcapibridge-0.1.2}/setup.cfg +0 -0
- {mcapibridge-0.1.1 → mcapibridge-0.1.2}/src/mc/__init__.py +0 -0
- {mcapibridge-0.1.1 → mcapibridge-0.1.2}/src/mcapibridge.egg-info/SOURCES.txt +0 -0
- {mcapibridge-0.1.1 → mcapibridge-0.1.2}/src/mcapibridge.egg-info/dependency_links.txt +0 -0
- {mcapibridge-0.1.1 → mcapibridge-0.1.2}/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.2
|
|
4
4
|
Summary: Python libary for MCAPIBridge
|
|
5
5
|
Author: TaotianZhufang
|
|
6
6
|
License: MIT License
|
|
@@ -133,7 +133,7 @@ Sets the text on a sign block.
|
|
|
133
133
|
|
|
134
134
|
#### `getOnlinePlayers()`
|
|
135
135
|
Get players' name online.
|
|
136
|
-
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]
|
|
136
|
+
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]`.
|
|
137
137
|
|
|
138
138
|
#### `getPlayerPos(target="")`
|
|
139
139
|
Get player's position and yaw and pitch.
|
|
@@ -245,7 +245,7 @@ Get click events.
|
|
|
245
245
|
* Double z
|
|
246
246
|
* **face**: Int click face.
|
|
247
247
|
* **entityId**: Int ID of clicking on entity.
|
|
248
|
-
* **action**: Int action type:1--left click,2--right click.(
|
|
248
|
+
* **action**: Int action type:1--left click,2--right click,101-105--Keyboard pressed.(Bind keys at Minecraft settings)
|
|
249
249
|
* **type**: String action:"LEFT_CLICK" or "RIGHT_CLICK"
|
|
250
250
|
|
|
251
251
|
#### `pollChatPosts()`
|
|
@@ -274,7 +274,7 @@ Represents a 3D vector/coordinate.
|
|
|
274
274
|
* **length()**: Returns vector length.
|
|
275
275
|
|
|
276
276
|
#### `PlayerPos`
|
|
277
|
-
**Inherits Vec3
|
|
277
|
+
**Inherits Vec3** Represents player position with rotation.
|
|
278
278
|
* **properties**: `x`,`y`,`z`,`yaw`,`pitch`.
|
|
279
279
|
* **Methods**:
|
|
280
280
|
* **forward(distance=1.0)**: Returns a new `Vec3` position at `distance` blocks ahead of the player's view.
|
|
@@ -1,248 +1,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
|
-
---
|
|
99
|
-
|
|
100
|
-
### Info
|
|
101
|
-
|
|
102
|
-
#### `getOnlinePlayers()`
|
|
103
|
-
Get players' name online.
|
|
104
|
-
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]
|
|
105
|
-
|
|
106
|
-
#### `getPlayerPos(target="")`
|
|
107
|
-
Get player's position and yaw and pitch.
|
|
108
|
-
* **target**: String player name.
|
|
109
|
-
* **return**: Int x,y,z and Double yaw,pitch.
|
|
110
|
-
|
|
111
|
-
#### `getPlayerEntityId(name)`
|
|
112
|
-
Get player's ID.
|
|
113
|
-
* **name**: String player name.
|
|
114
|
-
* **return**: Int ID.
|
|
115
|
-
|
|
116
|
-
#### `getPlayerName(entity_id)`
|
|
117
|
-
Get player's ID.
|
|
118
|
-
* **entity_id**: Int ID.
|
|
119
|
-
* **return**: String player name.
|
|
120
|
-
|
|
121
|
-
#### `getPlayerDetails(target="")`
|
|
122
|
-
Get player's details.
|
|
123
|
-
* **target**: String player name.
|
|
124
|
-
* **return**: Dict including
|
|
125
|
-
* `name`: String player name
|
|
126
|
-
* `id`: Int ID
|
|
127
|
-
* `mode`: String gamemode
|
|
128
|
-
* `health`: Double health
|
|
129
|
-
* `max_health`: Double max health
|
|
130
|
-
* `food`: Int food
|
|
131
|
-
* `held_item`: String item held
|
|
132
|
-
* `held_count`: Int item held count
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
### State
|
|
137
|
-
|
|
138
|
-
#### `setHealth(target, amount)`
|
|
139
|
-
Set player's health.
|
|
140
|
-
* **target**: String player name.
|
|
141
|
-
* **amount**: Double health.
|
|
142
|
-
|
|
143
|
-
#### `setFood(target, amount)`
|
|
144
|
-
Set player's food.
|
|
145
|
-
* **target**: String player name.
|
|
146
|
-
* **amount**: Int food(0-20).
|
|
147
|
-
|
|
148
|
-
#### `giveEffect(target, effect_name, duration_sec=30, amplifier=1)`
|
|
149
|
-
Effect player.
|
|
150
|
-
* **effect_name**: String effect ID.Ex:`"speed"`,`"night_vision"`.
|
|
151
|
-
* **duration_sec**: Int seconds.
|
|
152
|
-
* **amplifier**: Int amplifier.
|
|
153
|
-
|
|
154
|
-
#### `setFlying(target, allow_flight=True, is_flying=True)`
|
|
155
|
-
Enable player to fly in survival mode.
|
|
156
|
-
* **target**: String player name.
|
|
157
|
-
|
|
158
|
-
#### `setFlySpeed(target, speed=0.05)`
|
|
159
|
-
Set flight speed.
|
|
160
|
-
* **target**: String player name.
|
|
161
|
-
* **speed**: Double speed.Default 0.05.
|
|
162
|
-
|
|
163
|
-
#### `setWalkSpeed(target, speed=0.1)`
|
|
164
|
-
Set walk speed.
|
|
165
|
-
* **target**: String player name.
|
|
166
|
-
* **speed**: Double speed.Default 0.1.
|
|
167
|
-
|
|
168
|
-
#### `setGodMode(target, enable=True)`
|
|
169
|
-
Enable invulnerability.
|
|
170
|
-
* **target**: String player name.
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
### Inventory
|
|
175
|
-
|
|
176
|
-
#### `getInventory(target="")`
|
|
177
|
-
Get player's inventory.
|
|
178
|
-
* **return**: List of Dicts.Every dict has `{'slot': block_ID, 'id': item_ID, 'count': item_count}`.
|
|
179
|
-
|
|
180
|
-
#### `give(target, item_id, count=1)`
|
|
181
|
-
Give player item.
|
|
182
|
-
* **item_id**: String item ID.
|
|
183
|
-
* **count**: Int count.
|
|
184
|
-
|
|
185
|
-
#### `clearInventory(target, item_id="")`
|
|
186
|
-
Clear inventory.
|
|
187
|
-
* **target**: String player name.
|
|
188
|
-
* **item_id**: String item ID.
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
### TP
|
|
193
|
-
|
|
194
|
-
#### `teleport(x, y, z, target="")`
|
|
195
|
-
TP player.
|
|
196
|
-
* **x, y, z**: Int target x,y,z.
|
|
197
|
-
* **target**: String player ID.
|
|
198
|
-
|
|
199
|
-
#### `teleportEntity(entity_id, x, y, z)`
|
|
200
|
-
TP entitie.
|
|
201
|
-
* **entity_id**: Int entity id.
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
### Events
|
|
206
|
-
|
|
207
|
-
#### `pollBlockHits()`
|
|
208
|
-
Get click events.
|
|
209
|
-
* **return**: List Class `[BlockHit1,BlockHit2,.....]`
|
|
210
|
-
* **pos**: Class Vec3
|
|
211
|
-
* Double x
|
|
212
|
-
* Double y
|
|
213
|
-
* Double z
|
|
214
|
-
* **face**: Int click face.
|
|
215
|
-
* **entityId**: Int ID of clicking on entity.
|
|
216
|
-
* **action**: Int action type:1--left click,2--right click.(
|
|
217
|
-
* **type**: String action:"LEFT_CLICK" or "RIGHT_CLICK"
|
|
218
|
-
|
|
219
|
-
#### `pollChatPosts()`
|
|
220
|
-
Get player message events.
|
|
221
|
-
* **return**: List Class `[ChatPost1,ChatPost2,.....]`
|
|
222
|
-
* **name**: String player name.
|
|
223
|
-
* **message**: String message.
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
### Helper Methods
|
|
228
|
-
|
|
229
|
-
#### `getDirectionVector(target="")`
|
|
230
|
-
Calculates the direction vector based on a player's rotation. Useful for shooting projectiles.
|
|
231
|
-
* **target**: String player ID.
|
|
232
|
-
* **return**: Class `Vec3` normalized direction vector.
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
|
-
### Helper Classes
|
|
237
|
-
|
|
238
|
-
#### `Vec3`
|
|
239
|
-
Represents a 3D vector/coordinate.
|
|
240
|
-
* **properties**: `x`,`y`,`z`.
|
|
241
|
-
* **Methods**:
|
|
242
|
-
* **length()**: Returns vector length.
|
|
243
|
-
|
|
244
|
-
#### `PlayerPos`
|
|
245
|
-
**Inherits Vec3
|
|
246
|
-
* **properties**: `x`,`y`,`z`,`yaw`,`pitch`.
|
|
247
|
-
* **Methods**:
|
|
248
|
-
* **forward(distance=1.0)**: Returns a new `Vec3` position at `distance` blocks ahead of the player's view.
|
|
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
|
+
### Info
|
|
101
|
+
|
|
102
|
+
#### `getOnlinePlayers()`
|
|
103
|
+
Get players' name online.
|
|
104
|
+
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]`.
|
|
105
|
+
|
|
106
|
+
#### `getPlayerPos(target="")`
|
|
107
|
+
Get player's position and yaw and pitch.
|
|
108
|
+
* **target**: String player name.
|
|
109
|
+
* **return**: Int x,y,z and Double yaw,pitch.
|
|
110
|
+
|
|
111
|
+
#### `getPlayerEntityId(name)`
|
|
112
|
+
Get player's ID.
|
|
113
|
+
* **name**: String player name.
|
|
114
|
+
* **return**: Int ID.
|
|
115
|
+
|
|
116
|
+
#### `getPlayerName(entity_id)`
|
|
117
|
+
Get player's ID.
|
|
118
|
+
* **entity_id**: Int ID.
|
|
119
|
+
* **return**: String player name.
|
|
120
|
+
|
|
121
|
+
#### `getPlayerDetails(target="")`
|
|
122
|
+
Get player's details.
|
|
123
|
+
* **target**: String player name.
|
|
124
|
+
* **return**: Dict including
|
|
125
|
+
* `name`: String player name
|
|
126
|
+
* `id`: Int ID
|
|
127
|
+
* `mode`: String gamemode
|
|
128
|
+
* `health`: Double health
|
|
129
|
+
* `max_health`: Double max health
|
|
130
|
+
* `food`: Int food
|
|
131
|
+
* `held_item`: String item held
|
|
132
|
+
* `held_count`: Int item held count
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
### State
|
|
137
|
+
|
|
138
|
+
#### `setHealth(target, amount)`
|
|
139
|
+
Set player's health.
|
|
140
|
+
* **target**: String player name.
|
|
141
|
+
* **amount**: Double health.
|
|
142
|
+
|
|
143
|
+
#### `setFood(target, amount)`
|
|
144
|
+
Set player's food.
|
|
145
|
+
* **target**: String player name.
|
|
146
|
+
* **amount**: Int food(0-20).
|
|
147
|
+
|
|
148
|
+
#### `giveEffect(target, effect_name, duration_sec=30, amplifier=1)`
|
|
149
|
+
Effect player.
|
|
150
|
+
* **effect_name**: String effect ID.Ex:`"speed"`,`"night_vision"`.
|
|
151
|
+
* **duration_sec**: Int seconds.
|
|
152
|
+
* **amplifier**: Int amplifier.
|
|
153
|
+
|
|
154
|
+
#### `setFlying(target, allow_flight=True, is_flying=True)`
|
|
155
|
+
Enable player to fly in survival mode.
|
|
156
|
+
* **target**: String player name.
|
|
157
|
+
|
|
158
|
+
#### `setFlySpeed(target, speed=0.05)`
|
|
159
|
+
Set flight speed.
|
|
160
|
+
* **target**: String player name.
|
|
161
|
+
* **speed**: Double speed.Default 0.05.
|
|
162
|
+
|
|
163
|
+
#### `setWalkSpeed(target, speed=0.1)`
|
|
164
|
+
Set walk speed.
|
|
165
|
+
* **target**: String player name.
|
|
166
|
+
* **speed**: Double speed.Default 0.1.
|
|
167
|
+
|
|
168
|
+
#### `setGodMode(target, enable=True)`
|
|
169
|
+
Enable invulnerability.
|
|
170
|
+
* **target**: String player name.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### Inventory
|
|
175
|
+
|
|
176
|
+
#### `getInventory(target="")`
|
|
177
|
+
Get player's inventory.
|
|
178
|
+
* **return**: List of Dicts.Every dict has `{'slot': block_ID, 'id': item_ID, 'count': item_count}`.
|
|
179
|
+
|
|
180
|
+
#### `give(target, item_id, count=1)`
|
|
181
|
+
Give player item.
|
|
182
|
+
* **item_id**: String item ID.
|
|
183
|
+
* **count**: Int count.
|
|
184
|
+
|
|
185
|
+
#### `clearInventory(target, item_id="")`
|
|
186
|
+
Clear inventory.
|
|
187
|
+
* **target**: String player name.
|
|
188
|
+
* **item_id**: String item ID.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### TP
|
|
193
|
+
|
|
194
|
+
#### `teleport(x, y, z, target="")`
|
|
195
|
+
TP player.
|
|
196
|
+
* **x, y, z**: Int target x,y,z.
|
|
197
|
+
* **target**: String player ID.
|
|
198
|
+
|
|
199
|
+
#### `teleportEntity(entity_id, x, y, z)`
|
|
200
|
+
TP entitie.
|
|
201
|
+
* **entity_id**: Int entity id.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
### Events
|
|
206
|
+
|
|
207
|
+
#### `pollBlockHits()`
|
|
208
|
+
Get click events.
|
|
209
|
+
* **return**: List Class `[BlockHit1,BlockHit2,.....]`
|
|
210
|
+
* **pos**: Class Vec3
|
|
211
|
+
* Double x
|
|
212
|
+
* Double y
|
|
213
|
+
* Double z
|
|
214
|
+
* **face**: Int click face.
|
|
215
|
+
* **entityId**: Int ID of clicking on entity.
|
|
216
|
+
* **action**: Int action type:1--left click,2--right click,101-105--Keyboard pressed.(Bind keys at Minecraft settings)
|
|
217
|
+
* **type**: String action:"LEFT_CLICK" or "RIGHT_CLICK"
|
|
218
|
+
|
|
219
|
+
#### `pollChatPosts()`
|
|
220
|
+
Get player message events.
|
|
221
|
+
* **return**: List Class `[ChatPost1,ChatPost2,.....]`
|
|
222
|
+
* **name**: String player name.
|
|
223
|
+
* **message**: String message.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
### Helper Methods
|
|
228
|
+
|
|
229
|
+
#### `getDirectionVector(target="")`
|
|
230
|
+
Calculates the direction vector based on a player's rotation. Useful for shooting projectiles.
|
|
231
|
+
* **target**: String player ID.
|
|
232
|
+
* **return**: Class `Vec3` normalized direction vector.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### Helper Classes
|
|
237
|
+
|
|
238
|
+
#### `Vec3`
|
|
239
|
+
Represents a 3D vector/coordinate.
|
|
240
|
+
* **properties**: `x`,`y`,`z`.
|
|
241
|
+
* **Methods**:
|
|
242
|
+
* **length()**: Returns vector length.
|
|
243
|
+
|
|
244
|
+
#### `PlayerPos`
|
|
245
|
+
**Inherits Vec3** Represents player position with rotation.
|
|
246
|
+
* **properties**: `x`,`y`,`z`,`yaw`,`pitch`.
|
|
247
|
+
* **Methods**:
|
|
248
|
+
* **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):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcapibridge
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Python libary for MCAPIBridge
|
|
5
5
|
Author: TaotianZhufang
|
|
6
6
|
License: MIT License
|
|
@@ -133,7 +133,7 @@ Sets the text on a sign block.
|
|
|
133
133
|
|
|
134
134
|
#### `getOnlinePlayers()`
|
|
135
135
|
Get players' name online.
|
|
136
|
-
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]
|
|
136
|
+
* **return**: Dict: `[{'name': 'Steve', 'id': 123}, ...]`.
|
|
137
137
|
|
|
138
138
|
#### `getPlayerPos(target="")`
|
|
139
139
|
Get player's position and yaw and pitch.
|
|
@@ -245,7 +245,7 @@ Get click events.
|
|
|
245
245
|
* Double z
|
|
246
246
|
* **face**: Int click face.
|
|
247
247
|
* **entityId**: Int ID of clicking on entity.
|
|
248
|
-
* **action**: Int action type:1--left click,2--right click.(
|
|
248
|
+
* **action**: Int action type:1--left click,2--right click,101-105--Keyboard pressed.(Bind keys at Minecraft settings)
|
|
249
249
|
* **type**: String action:"LEFT_CLICK" or "RIGHT_CLICK"
|
|
250
250
|
|
|
251
251
|
#### `pollChatPosts()`
|
|
@@ -274,7 +274,7 @@ Represents a 3D vector/coordinate.
|
|
|
274
274
|
* **length()**: Returns vector length.
|
|
275
275
|
|
|
276
276
|
#### `PlayerPos`
|
|
277
|
-
**Inherits Vec3
|
|
277
|
+
**Inherits Vec3** Represents player position with rotation.
|
|
278
278
|
* **properties**: `x`,`y`,`z`,`yaw`,`pitch`.
|
|
279
279
|
* **Methods**:
|
|
280
280
|
* **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
|