py2hackCraft2 1.0.7__tar.gz → 1.0.9__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.
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/PKG-INFO +1 -1
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/py2hackCraft/modules.py +82 -19
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/py2hackCraft2.egg-info/PKG-INFO +1 -1
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/setup.py +1 -1
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/README.md +0 -0
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/py2hackCraft/__init__.py +0 -0
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/py2hackCraft/material.py +0 -0
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/py2hackCraft2.egg-info/SOURCES.txt +0 -0
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/py2hackCraft2.egg-info/dependency_links.txt +0 -0
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/py2hackCraft2.egg-info/requires.txt +0 -0
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/py2hackCraft2.egg-info/top_level.txt +0 -0
- {py2hackCraft2-1.0.7 → py2hackCraft2-1.0.9}/setup.cfg +0 -0
|
@@ -119,6 +119,7 @@ class _WebSocketClient:
|
|
|
119
119
|
logging.debug("send sending'%s'" % message)
|
|
120
120
|
self.wait_for_connection()
|
|
121
121
|
with self.lock:
|
|
122
|
+
self.result = None
|
|
122
123
|
self.response_event.clear() # イベントをクリアして新しいレスポンスの準備をする
|
|
123
124
|
self.ws.send(message)
|
|
124
125
|
self.response_event.wait() # サーバーからのレスポンスを待つ
|
|
@@ -145,6 +146,19 @@ class Location:
|
|
|
145
146
|
z: int
|
|
146
147
|
world: str = "world"
|
|
147
148
|
|
|
149
|
+
@dataclass
|
|
150
|
+
class InteractEvent:
|
|
151
|
+
action: str
|
|
152
|
+
type: str
|
|
153
|
+
name: str
|
|
154
|
+
block: str = None
|
|
155
|
+
data: int = 0
|
|
156
|
+
uuid: str = None
|
|
157
|
+
world: str = "world"
|
|
158
|
+
x: int = 0
|
|
159
|
+
y: int = 0
|
|
160
|
+
z: int = 0
|
|
161
|
+
|
|
148
162
|
@dataclass
|
|
149
163
|
class EventMessage:
|
|
150
164
|
"""
|
|
@@ -204,11 +218,13 @@ class Block:
|
|
|
204
218
|
isOccluding (bool): 透過しないブロックかどうか。
|
|
205
219
|
isSolid (bool): 壁のあるブロックかどうか。
|
|
206
220
|
isPassable (bool): 通過可能なブロックかどうか。
|
|
221
|
+
world (str): ブロックが存在するワールドの名前(デフォルトは"world")。
|
|
207
222
|
x (int): ブロックのX座標。
|
|
208
223
|
y (int): ブロックのY座標。
|
|
209
224
|
z (int): ブロックのZ座標。
|
|
210
225
|
"""
|
|
211
226
|
name: str
|
|
227
|
+
type: str = "block"
|
|
212
228
|
data: int = 0
|
|
213
229
|
isLiquid: bool = False
|
|
214
230
|
isAir: bool = False
|
|
@@ -220,6 +236,7 @@ class Block:
|
|
|
220
236
|
x: int = 0
|
|
221
237
|
y: int = 0
|
|
222
238
|
z: int = 0
|
|
239
|
+
world: str = "world"
|
|
223
240
|
|
|
224
241
|
@dataclass
|
|
225
242
|
class ItemStack:
|
|
@@ -249,6 +266,18 @@ class Player:
|
|
|
249
266
|
def logout(self):
|
|
250
267
|
self.client.disconnect()
|
|
251
268
|
|
|
269
|
+
def setOnBlockBreak(self, callbackFunc: Callable[['Block'], Any]):
|
|
270
|
+
"""
|
|
271
|
+
プレイヤーがブロックをこわした時に呼び出されるコールバック関数を設定する。
|
|
272
|
+
"""
|
|
273
|
+
def callbackWrapper(data):
|
|
274
|
+
logging.debug("onPlayerBlockBreak callbackWrapper '%s'" % data)
|
|
275
|
+
if(data['playerUuid'] == self.uuid):
|
|
276
|
+
logging.debug("callbackWrapper '%s'" % data)
|
|
277
|
+
block = Block(**data['block'])
|
|
278
|
+
callbackFunc(self, block)
|
|
279
|
+
self.client.setCallback('onPlayerBlockBreak', callbackWrapper)
|
|
280
|
+
|
|
252
281
|
def getEntity(self, name: str) -> 'Entity':
|
|
253
282
|
"""
|
|
254
283
|
指定された名前のエンティティを取得する。
|
|
@@ -270,11 +299,11 @@ class Player:
|
|
|
270
299
|
"data": {"entity": name}
|
|
271
300
|
}
|
|
272
301
|
self.client.send(json.dumps(message))
|
|
273
|
-
|
|
274
|
-
if(
|
|
302
|
+
result = self.client.result
|
|
303
|
+
if(result is None):
|
|
275
304
|
raise ValueError("Entity '%s' not found" % name)
|
|
276
305
|
|
|
277
|
-
return Entity(self.client, self.world,
|
|
306
|
+
return Entity(self.client, self.world, result)
|
|
278
307
|
|
|
279
308
|
class World:
|
|
280
309
|
"""
|
|
@@ -285,7 +314,7 @@ class World:
|
|
|
285
314
|
self.name = world
|
|
286
315
|
self.entityUUID = entityUUID
|
|
287
316
|
|
|
288
|
-
def setBlock(self, x: int, y: int, z: int, block: str):
|
|
317
|
+
def setBlock(self, x: int, y: int, z: int, block: str, data: int = 0):
|
|
289
318
|
"""
|
|
290
319
|
指定された座標にブロックを設置する。
|
|
291
320
|
|
|
@@ -295,7 +324,7 @@ class World:
|
|
|
295
324
|
z (int): 絶対的なZ座標。
|
|
296
325
|
block (str): 設置するブロックの種類。
|
|
297
326
|
"""
|
|
298
|
-
self.client.sendCall(self.entityUUID, "setBlock", [x, y, z, block])
|
|
327
|
+
self.client.sendCall(self.entityUUID, "setBlock", [x, y, z, block, data])
|
|
299
328
|
|
|
300
329
|
def getBlock(self, x: int, y: int, z: int) -> Block :
|
|
301
330
|
"""
|
|
@@ -391,6 +420,7 @@ class Entity:
|
|
|
391
420
|
self.client = client
|
|
392
421
|
self.world = world
|
|
393
422
|
self.uuid = uuid
|
|
423
|
+
self.positions = []
|
|
394
424
|
|
|
395
425
|
def setOnPlayerChat(self, callbackFunc: Callable[['Entity', 'ChatMessage'], Any]):
|
|
396
426
|
"""
|
|
@@ -415,6 +445,18 @@ class Entity:
|
|
|
415
445
|
callbackFunc(self, power)
|
|
416
446
|
self.client.setCallback('onEntityRedstone', callbackWrapper)
|
|
417
447
|
|
|
448
|
+
def setOnInteractEvent(self, callbackFunc: Callable[['Entity', 'InteractEvent'], Any]):
|
|
449
|
+
"""
|
|
450
|
+
レッドストーンを受信したときに呼び出されるコールバック関数を設定する。
|
|
451
|
+
"""
|
|
452
|
+
def callbackWrapper(data):
|
|
453
|
+
logging.debug("onInteractEvent callbackWrapper '%s'" % data)
|
|
454
|
+
if(data['entityUuid'] == self.uuid):
|
|
455
|
+
logging.debug("callbackWrapper '%s'" % data)
|
|
456
|
+
event = InteractEvent(**data["event"])
|
|
457
|
+
callbackFunc(self, event)
|
|
458
|
+
self.client.setCallback('onInteractEvent', callbackWrapper)
|
|
459
|
+
|
|
418
460
|
def setOnMessage(self, callbackFunc: Callable[['Entity', str], Any]):
|
|
419
461
|
"""
|
|
420
462
|
メッセージを受信したときに呼び出されるコールバック関数を設定する。
|
|
@@ -437,6 +479,15 @@ class Entity:
|
|
|
437
479
|
"""
|
|
438
480
|
self.client.sendCall(self.uuid, "sendEvent", [target, message])
|
|
439
481
|
|
|
482
|
+
def executeCommand(self, command: str):
|
|
483
|
+
"""
|
|
484
|
+
コマンドを実行する。
|
|
485
|
+
|
|
486
|
+
Args:
|
|
487
|
+
command (str): 実行するコマンドの内容。
|
|
488
|
+
"""
|
|
489
|
+
self.client.sendCall(self.uuid, "executeCommand", [command])
|
|
490
|
+
|
|
440
491
|
def getWorld(self) -> 'World':
|
|
441
492
|
"""
|
|
442
493
|
指定された名前のワールドを取得する。
|
|
@@ -460,6 +511,25 @@ class Entity:
|
|
|
460
511
|
inventory = Inventory(self.client, self.uuid, ** json.loads(self.client.result))
|
|
461
512
|
return inventory
|
|
462
513
|
|
|
514
|
+
def push(self) -> bool :
|
|
515
|
+
"""
|
|
516
|
+
自分の位置を保存する。
|
|
517
|
+
"""
|
|
518
|
+
pos = self.getLocation()
|
|
519
|
+
self.positions.append(pos)
|
|
520
|
+
return True
|
|
521
|
+
|
|
522
|
+
def pop(self) -> bool :
|
|
523
|
+
"""
|
|
524
|
+
自分の位置を保存した位置に戻す。
|
|
525
|
+
"""
|
|
526
|
+
if(len(self.positions) > 0):
|
|
527
|
+
pos = self.positions.pop()
|
|
528
|
+
self.teleport(pos.x, pos.y, pos.z)
|
|
529
|
+
return True
|
|
530
|
+
else:
|
|
531
|
+
return False
|
|
532
|
+
|
|
463
533
|
def forward(self) -> bool :
|
|
464
534
|
"""
|
|
465
535
|
自分を前方に移動させる。
|
|
@@ -521,31 +591,24 @@ class Entity:
|
|
|
521
591
|
self.client.sendCall(self.uuid, "sound")
|
|
522
592
|
return str_to_bool(self.client.result)
|
|
523
593
|
|
|
524
|
-
def
|
|
594
|
+
def move(self, speed: float) -> bool :
|
|
525
595
|
"""
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
"""
|
|
529
|
-
self.client.sendCall(self.uuid, "move", [0.5])
|
|
530
|
-
return str_to_bool(self.client.result)
|
|
531
|
-
|
|
532
|
-
def sprint(self) -> bool :
|
|
533
|
-
"""
|
|
534
|
-
走る。
|
|
596
|
+
前方へ移動する。
|
|
535
597
|
|
|
598
|
+
Args:
|
|
599
|
+
speed (float): 移動速度。
|
|
536
600
|
"""
|
|
537
|
-
self.client.sendCall(self.uuid, "move", [
|
|
601
|
+
self.client.sendCall(self.uuid, "move", [speed])
|
|
538
602
|
return str_to_bool(self.client.result)
|
|
539
603
|
|
|
540
|
-
def turn(self, degrees: int)
|
|
604
|
+
def turn(self, degrees: int):
|
|
541
605
|
"""
|
|
542
606
|
自分を回転させる。
|
|
543
607
|
|
|
544
608
|
Args:
|
|
545
609
|
degrees (int): 回転する速度。
|
|
546
610
|
"""
|
|
547
|
-
self.client.sendCall(self.uuid, "turn", [degrees])
|
|
548
|
-
return str_to_bool(self.client.result)
|
|
611
|
+
self.client.sendCall(self.uuid, "turn", [degrees])
|
|
549
612
|
|
|
550
613
|
def jump(self) -> bool :
|
|
551
614
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|