py2hackCraft2 1.0.20__tar.gz → 1.0.22__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2hackCraft2
3
- Version: 1.0.20
3
+ Version: 1.0.22
4
4
  Summary: These are APIs that connect to the hackCraft2 server from Python to manipulate pets.
5
5
  Home-page: https://pypi.org/project/py2hackCraft2/
6
6
  Author: Masafumi Terazono
@@ -8,13 +8,13 @@ from typing import Callable, Any
8
8
 
9
9
  def str_to_bool(s):
10
10
  """
11
- 文字列をブール値に変換する。
11
+ 文字列をブール値に変換する
12
12
 
13
13
  Args:
14
14
  s (str): "true" または "false"(大文字小文字は無視)
15
15
 
16
16
  Returns:
17
- bool: 変換されたブール値。"true"ならTrue、"false"ならFalse
17
+ bool: 変換されたブール値"true"ならTrue、"false"ならFalse
18
18
  """
19
19
  if s.lower() == 'true':
20
20
  return True
@@ -24,7 +24,7 @@ def str_to_bool(s):
24
24
  raise ValueError(f"Cannot covert {s} to a boolean.") # 有効な文字列でない場合はエラー
25
25
 
26
26
  class UninitializedClientError(Exception):
27
- """WebSocketClientが初期化されていないことを示すカスタム例外。"""
27
+ """WebSocketClientが初期化されていないことを示すカスタム例外"""
28
28
  pass
29
29
 
30
30
 
@@ -175,13 +175,13 @@ class Side:
175
175
  @dataclass
176
176
  class Location:
177
177
  """
178
- 座標を表すデータクラス。
178
+ 座標を表すデータクラス
179
179
 
180
180
  Attributes:
181
- x (str): X座標。
182
- y (str): Y座標。
183
- z (str): Z座標。
184
- world (str): ワールド名。
181
+ x (str): X座標
182
+ y (str): Y座標
183
+ z (str): Z座標
184
+ world (str): ワールド名
185
185
  """
186
186
  x: int
187
187
  y: int
@@ -191,20 +191,20 @@ class Location:
191
191
  @dataclass
192
192
  class InteractEvent:
193
193
  """
194
- クリックイベントを表すデータクラス。
194
+ クリックイベントを表すデータクラス
195
195
 
196
196
  Attributes:
197
- action (str): アクションの名前。
198
- player (str): クリックしたプレイヤー名。
199
- player_uuid (str): クリックしたプレイヤーの一意の識別子(UUID)。
200
- event (str): アイテムに設定されている名前。
197
+ action (str): アクションの名前
198
+ player (str): クリックしたプレイヤー名
199
+ player_uuid (str): クリックしたプレイヤーの一意の識別子(UUID
200
+ event (str): アイテムに設定されている名前
201
201
  name (str): ブロックあるいはエンティティーの名前
202
- type (str): ブロックあるいはエンティティーの種類。
203
- data (int): ブロックのデータ値。
204
- world (str): ブロックあるいはエンティティーのいたワールド名。
205
- x (int): クリックした場所のワールドにおけるX座標。
206
- y (int): クリックした場所のワールドにおけるY座標。
207
- z (int): クリックした場所のワールドにおけるZ座標。
202
+ type (str): ブロックあるいはエンティティーの種類
203
+ data (int): ブロックのデータ値
204
+ world (str): ブロックあるいはエンティティーのいたワールド名
205
+ x (int): クリックした場所のワールドにおけるX座標
206
+ y (int): クリックした場所のワールドにおけるY座標
207
+ z (int): クリックした場所のワールドにおけるZ座標
208
208
  """
209
209
  action: str
210
210
  player: str
@@ -221,12 +221,12 @@ class InteractEvent:
221
221
  @dataclass
222
222
  class EventMessage:
223
223
  """
224
- イベントメッセージを表すデータクラス。
224
+ イベントメッセージを表すデータクラス
225
225
 
226
226
  Attributes:
227
- sender (str): 送信者の名前。
228
- uuid (str): 送信者の一意の識別子(UUID)。
229
- message (str): イベントメッセージ。
227
+ sender (str): 送信者の名前
228
+ uuid (str): 送信者の一意の識別子(UUID
229
+ message (str): イベントメッセージ
230
230
  """
231
231
  entityUuid: str
232
232
  sender: str
@@ -237,12 +237,12 @@ class EventMessage:
237
237
  @dataclass
238
238
  class ChatMessage:
239
239
  """
240
- チャットメッセージを表すデータクラス。
240
+ チャットメッセージを表すデータクラス
241
241
 
242
242
  Attributes:
243
- player (str): プレイヤー名。
244
- uuid (str): プレイヤーの一意の識別子(UUID)。
245
- message (str): プレイヤーがチャットで送信したメッセージの内容。
243
+ player (str): プレイヤー名
244
+ uuid (str): プレイヤーの一意の識別子(UUID
245
+ message (str): プレイヤーがチャットで送信したメッセージの内容
246
246
  """
247
247
  player: str
248
248
  uuid: str
@@ -252,7 +252,7 @@ class ChatMessage:
252
252
  @dataclass
253
253
  class RedstonePower:
254
254
  """
255
- レッドストーン信号を表すデータクラス。
255
+ レッドストーン信号を表すデータクラス
256
256
 
257
257
  Attributes:
258
258
  oldCurrent (int): 前のレッドストーン信号の強さ
@@ -265,22 +265,22 @@ class RedstonePower:
265
265
  @dataclass
266
266
  class Block:
267
267
  """
268
- ブロックを表すデータクラス。
268
+ ブロックを表すデータクラス
269
269
 
270
270
  Attributes:
271
- name (str): ブロックの種類。
272
- data (int): ブロックのデータ値。
273
- isLiquid (bool): 液体ブロックかどうか。
274
- isAir (bool): 空気ブロックかどうか。
275
- isBurnable (bool): 燃えるブロックかどうか。
276
- isFuel (bool): 燃料ブロックかどうか。
277
- isOccluding (bool): 透過しないブロックかどうか。
278
- isSolid (bool): 壁のあるブロックかどうか。
279
- isPassable (bool): 通過可能なブロックかどうか。
280
- world (str): ブロックが存在するワールドの名前(デフォルトは"world")。
281
- x (int): ブロックのX座標。
282
- y (int): ブロックのY座標。
283
- z (int): ブロックのZ座標。
271
+ name (str): ブロックの種類
272
+ data (int): ブロックのデータ値
273
+ isLiquid (bool): 液体ブロックかどうか
274
+ isAir (bool): 空気ブロックかどうか
275
+ isBurnable (bool): 燃えるブロックかどうか
276
+ isFuel (bool): 燃料ブロックかどうか
277
+ isOccluding (bool): 透過しないブロックかどうか
278
+ isSolid (bool): 壁のあるブロックかどうか
279
+ isPassable (bool): 通過可能なブロックかどうか
280
+ world (str): ブロックが存在するワールドの名前(デフォルトは"world"
281
+ x (int): ブロックのX座標
282
+ y (int): ブロックのY座標
283
+ z (int): ブロックのZ座標
284
284
  """
285
285
  name: str
286
286
  type: str = "block"
@@ -328,16 +328,16 @@ class Player:
328
328
 
329
329
  def getEntity(self, name: str) -> 'Entity':
330
330
  """
331
- 指定された名前のエンティティを取得する。
331
+ 指定された名前のエンティティを取得する
332
332
 
333
333
  Args:
334
- name (str): エンティティの名前。
334
+ name (str): エンティティの名前
335
335
 
336
336
  Returns:
337
- Entity: 取得したエンティティ。
337
+ Entity: 取得したエンティティ
338
338
 
339
339
  Raises:
340
- UninitializedClientError: クライアントが初期化されていない場合。
340
+ UninitializedClientError: クライアントが初期化されていない場合
341
341
  """
342
342
  if self.client is None or not self.client.connected: # 接続状態をチェック
343
343
  raise UninitializedClientError("Client is not initialized")
@@ -362,7 +362,7 @@ class Player:
362
362
 
363
363
  class Inventory:
364
364
  """
365
- インベントリを表すクラス。
365
+ インベントリを表すクラス
366
366
  """
367
367
  def __init__(self, client: _WebSocketClient, entityUUID: str, world: str, x: int, y: int, z:int, size:int):
368
368
  self.client = client
@@ -372,10 +372,10 @@ class Inventory:
372
372
 
373
373
  def getItem(self, slot: int) -> ItemStack :
374
374
  """
375
- 指定されたスロットのアイテムを取得する。
375
+ 指定されたスロットのアイテムを取得する
376
376
 
377
377
  Args:
378
- slot (int): 取得するアイテムのスロット番号。
378
+ slot (int): 取得するアイテムのスロット番号
379
379
  """
380
380
  self.client.sendCall(self.entityUUID, "getInventoryItem", [self.location.x, self.location.y, self.location.z, slot])
381
381
  itemStack = ItemStack(** json.loads(self.client.result))
@@ -383,21 +383,21 @@ class Inventory:
383
383
 
384
384
  def swapItem(self, slot1: int, slot2: int) :
385
385
  """
386
- インベントリの内容を置き換える。
386
+ インベントリの内容を置き換える
387
387
 
388
388
  Args:
389
- slot1 (int): 置き換え元のアイテムのスロット番号。
390
- slot2 (int): 置き換え先のアイテムのスロット番号。
389
+ slot1 (int): 置き換え元のアイテムのスロット番号
390
+ slot2 (int): 置き換え先のアイテムのスロット番号
391
391
  """
392
392
  self.client.sendCall(self.entityUUID, "swapInventoryItem", [self.location.x, self.location.y, self.location.z, slot1, slot2])
393
393
 
394
394
  def moveItem(self, slot1: int, slot2: int) :
395
395
  """
396
- インベントリの内容を移動させる。
396
+ インベントリの内容を移動させる
397
397
 
398
398
  Args:
399
- slot1 (int): 移動元のアイテムのスロット番号。
400
- slot2 (int): 移動先のアイテムのスロット番号。
399
+ slot1 (int): 移動元のアイテムのスロット番号
400
+ slot2 (int): 移動先のアイテムのスロット番号
401
401
  """
402
402
  self.client.sendCall(self.entityUUID, "moveInventoryItem", [self.location.x, self.location.y, self.location.z, slot1, slot2])
403
403
 
@@ -406,8 +406,8 @@ class Inventory:
406
406
  チェストを開いたエンティティーのインベントリからこのインベントリにアイテムを入れる
407
407
 
408
408
  Args:
409
- slot1 (int): 引き出し元のアイテムのスロット番号。
410
- slot2 (int): 格納先のアイテムのスロット番号。
409
+ slot1 (int): 引き出し元のアイテムのスロット番号
410
+ slot2 (int): 格納先のアイテムのスロット番号
411
411
  """
412
412
  self.client.sendCall(self.entityUUID, "storeInventoryItem", [self.location.x, self.location.y, self.location.z, slot1, slot2])
413
413
 
@@ -416,15 +416,15 @@ class Inventory:
416
416
  チェストを開いたエンティティーのインベントリからこのインベントリからアイテムを取り出す
417
417
 
418
418
  Args:
419
- slot1 (int): 格納先のアイテムのスロット番号。
420
- slot2 (int): 引き出し元のアイテムのスロット番号。
419
+ slot1 (int): 格納先のアイテムのスロット番号
420
+ slot2 (int): 引き出し元のアイテムのスロット番号
421
421
  """
422
422
  self.client.sendCall(self.entityUUID, "retrieveInventoryItem", [self.location.x, self.location.y, self.location.z, slot1, slot2])
423
423
 
424
424
 
425
425
  class Entity:
426
426
  """
427
- エンティティを表すクラス。
427
+ エンティティを表すクラス
428
428
  """
429
429
  def __init__(self, client: _WebSocketClient, world: str, uuid: str):
430
430
  self.client = client
@@ -445,21 +445,21 @@ class Entity:
445
445
 
446
446
  def waitForRedstoneChange(self):
447
447
  """
448
- レッドストーン信号が変わるまでまつ。
448
+ レッドストーン信号が変わるまでまつ
449
449
  """
450
450
  self.client.waitFor(self.uuid, 'onEntityRedstone')
451
451
  return RedstonePower(** self.client.result)
452
452
 
453
453
  def waitForBreakBlock(self):
454
454
  """
455
- プレイヤーがブロックをこわすまで待つ。
455
+ プレイヤーがブロックをこわすまで待つ
456
456
  """
457
457
  self.client.waitFor(self.uuid, 'onPlayerBlockBreak')
458
458
  return Block(** self.client.result)
459
459
 
460
460
  def setOnInteractEvent(self, callbackFunc: Callable[['Entity', 'InteractEvent'], Any]):
461
461
  """
462
- プレイヤーがイベントアイテムを使った時に呼び出されるコールバック関数を設定する。
462
+ プレイヤーがイベントアイテムを使った時に呼び出されるコールバック関数を設定する
463
463
  """
464
464
  def callbackWrapper(data):
465
465
  logging.debug("onInteractEvent callbackWrapper '%s'" % data)
@@ -471,7 +471,7 @@ class Entity:
471
471
 
472
472
  def setOnMessage(self, callbackFunc: Callable[['Entity', str], Any]):
473
473
  """
474
- カスタムイベントメッセージを受信したときに呼び出されるコールバック関数を設定する。
474
+ カスタムイベントメッセージを受信したときに呼び出されるコールバック関数を設定する
475
475
  """
476
476
  def callbackWrapper(data):
477
477
  logging.debug("setOnMessage callbackWrapper '%s'" % data)
@@ -483,20 +483,20 @@ class Entity:
483
483
 
484
484
  def sendMessage(self, target: str, message: str):
485
485
  """
486
- カスタムイベントメッセージを送信する。
486
+ カスタムイベントメッセージを送信する
487
487
 
488
488
  Args:
489
- target (str): 送信先のEntityの名前。
490
- message (str): 送信するメッセージの内容。
489
+ target (str): 送信先のEntityの名前
490
+ message (str): 送信するメッセージの内容
491
491
  """
492
492
  self.client.sendCall(self.uuid, "sendEvent", [target, message])
493
493
 
494
494
  def executeCommand(self, command: str):
495
495
  """
496
- コマンドを実行する。
496
+ コマンドを実行する
497
497
 
498
498
  Args:
499
- command (str): 実行するコマンドの内容。
499
+ command (str): 実行するコマンドの内容
500
500
  """
501
501
  self.client.sendCall(self.uuid, "executeCommand", [command])
502
502
 
@@ -507,7 +507,7 @@ class Entity:
507
507
 
508
508
  def push(self) -> bool :
509
509
  """
510
- 自分の位置を保存する。
510
+ 自分の位置を保存する
511
511
  """
512
512
  pos = self.getLocation()
513
513
  self.positions.append(pos)
@@ -515,7 +515,7 @@ class Entity:
515
515
 
516
516
  def pop(self) -> bool :
517
517
  """
518
- 自分の位置を保存した位置に戻す。
518
+ 自分の位置を保存した位置に戻す
519
519
  """
520
520
  if(len(self.positions) > 0):
521
521
  pos = self.positions.pop()
@@ -526,68 +526,68 @@ class Entity:
526
526
 
527
527
  def forward(self) -> bool :
528
528
  """
529
- 自分を前方に移動させる。
529
+ 自分を前方に移動させる
530
530
  """
531
531
  self.client.sendCall(self.uuid, "forward")
532
532
  return str_to_bool(self.client.result)
533
533
 
534
534
  def back(self) -> bool :
535
535
  """
536
- 自分を後方に移動させる。
536
+ 自分を後方に移動させる
537
537
  """
538
538
  self.client.sendCall(self.uuid, "back")
539
539
  return str_to_bool(self.client.result)
540
540
 
541
541
  def up(self) -> bool :
542
542
  """
543
- 自分を上方に移動させる。
543
+ 自分を上方に移動させる
544
544
  """
545
545
  self.client.sendCall(self.uuid, "up")
546
546
  return str_to_bool(self.client.result)
547
547
 
548
548
  def down(self) -> bool :
549
549
  """
550
- 自分を下方に移動させる。
550
+ 自分を下方に移動させる
551
551
  """
552
552
  self.client.sendCall(self.uuid, "down")
553
553
  return str_to_bool(self.client.result)
554
554
 
555
555
  def stepLeft(self) -> bool :
556
556
  """
557
- 自分を左に移動させる。
557
+ 自分を左に移動させる
558
558
  """
559
559
  self.client.sendCall(self.uuid, "stepLeft")
560
560
  return str_to_bool(self.client.result)
561
561
 
562
562
  def stepRight(self) -> bool :
563
563
  """
564
- 自分を右に移動させる。
564
+ 自分を右に移動させる
565
565
  """
566
566
  self.client.sendCall(self.uuid, "stepRight")
567
567
  return str_to_bool(self.client.result)
568
568
 
569
569
  def turnLeft(self) :
570
570
  """
571
- 自分を左に回転させる。aw
571
+ 自分を左に回転させるaw
572
572
  """
573
573
  self.client.sendCall(self.uuid, "turnLeft")
574
574
 
575
575
  def turnRight(self) :
576
576
  """
577
- 自分を右に回転させる。
577
+ 自分を右に回転させる
578
578
  """
579
579
  self.client.sendCall(self.uuid, "turnRight")
580
580
 
581
581
  def makeSound(self) -> bool :
582
582
  """
583
- 自分を鳴かせる。
583
+ 自分を鳴かせる
584
584
  """
585
585
  self.client.sendCall(self.uuid, "sound")
586
586
  return str_to_bool(self.client.result)
587
587
 
588
588
  def addForce(self, x: float, y: float, z: float) -> bool :
589
589
  """
590
- 前方へ移動する。
590
+ 前方へ移動する
591
591
 
592
592
  Args:
593
593
  x (float): x軸方向の加速
@@ -599,78 +599,76 @@ class Entity:
599
599
 
600
600
  def jump(self, degrees: int):
601
601
  """
602
- ジャンプさせる。
602
+ ジャンプさせる
603
603
  """
604
604
  self.client.sendCall(self.uuid, "jump")
605
605
 
606
606
  def turn(self, degrees: int):
607
607
  """
608
- 自分を回転させる。
608
+ 自分を回転させる
609
609
 
610
610
  Args:
611
- degrees (int): 回転する速度。
611
+ degrees (int): 回転する速度
612
612
  """
613
613
  self.client.sendCall(self.uuid, "turn", [degrees])
614
614
 
615
- def placeX(self, cord: Coordinates, x: int, y: int, z: int, block=None, side=None) -> bool :
615
+ def placeX(self, x: int, y: int, z: int, cord: Coordinates=Coordinates.local, side=None,) -> bool :
616
616
  """
617
- 指定した座標にブロックを設置する。
617
+ 指定した座標にブロックを設置する
618
618
 
619
619
  Args:
620
- cord (Coordinates): 座標の種類('', '^', '~')。
621
- x (int): X座標。
622
- y (int): Y座標。
623
- z (int): Z座標。
624
- block (str): 設置するブロックの種類。
625
- side (str): 設置する面。
626
- """
627
- self.client.sendCall(self.uuid, "placeX", [x, y, z, cord, side, block])
620
+ x (int): X座標
621
+ y (int): Y座標
622
+ z (int): Z座標
623
+ cord (Coordinates): 座標の種類('', '^', '~')
624
+ side (str): 設置する面
625
+ """
626
+ self.client.sendCall(self.uuid, "placeX", [x, y, z, cord, side])
628
627
  return str_to_bool(self.client.result)
629
628
 
630
- def placeHere(self, x: int, y: int, z: int, block=None, side=None) -> bool :
629
+ def placeHere(self, x: int, y: int, z: int, side=None) -> bool :
631
630
  """
632
- 自分を中心に指定した座標にブロックを設置する。
631
+ 自分を中心に指定した座標にブロックを設置する
633
632
 
634
633
  Args:
635
- x (int): X座標。
636
- y (int): Y座標。
637
- z (int): Z座標。
638
- block (str): 設置するブロックの種類。
639
- side (str): 設置する面。
634
+ x (int): X座標
635
+ y (int): Y座標
636
+ z (int): Z座標
637
+ side (str): 設置する面
640
638
  """
641
- self.client.sendCall(self.uuid, "placeX", [x, y, z, "^", side, block])
639
+ self.client.sendCall(self.uuid, "placeX", [x, y, z, "^", side])
642
640
  return str_to_bool(self.client.result)
643
641
 
644
642
  def place(self, side=None) -> bool :
645
643
  """
646
- 自分の前方にブロックを設置する。
644
+ 自分の前方にブロックを設置する
647
645
  """
648
646
  self.client.sendCall(self.uuid, "placeFront", [side])
649
647
  return str_to_bool(self.client.result)
650
648
 
651
649
  def placeUp(self, side=None) -> bool :
652
650
  """
653
- 自分の真上にブロックを設置する。
651
+ 自分の真上にブロックを設置する
654
652
  """
655
653
  self.client.sendCall(self.uuid, "placeUp", [side])
656
654
  return str_to_bool(self.client.result)
657
655
 
658
656
  def placeDown(self, side=None) -> bool :
659
657
  """
660
- 自分の真下にブロックを設置する。
658
+ 自分の真下にブロックを設置する
661
659
  """
662
660
  self.client.sendCall(self.uuid, "placeDown", [side])
663
661
  return str_to_bool(self.client.result)
664
662
 
665
- def useItemX(self, cord: Coordinates, x: int, y: int, z: int) -> bool :
663
+ def useItemX(self, x: int, y: int, z: int, cord: Coordinates = Coordinates.local) -> bool :
666
664
  """
667
665
  指定した座標にアイテムを使う
668
666
 
669
667
  Args:
670
- cord (Coordinates): 座標の種類('', '^', '~')。
671
- x (int): X座標。
672
- y (int): Y座標。
673
- z (int): Z座標。
668
+ x (int): X座標
669
+ y (int): Y座標
670
+ z (int): Z座標
671
+ cord (Coordinates): 座標の種類('', '^', '~')
674
672
  """
675
673
  self.client.sendCall(self.uuid, "useItemX", [x, y, z, cord])
676
674
  return str_to_bool(self.client.result)
@@ -680,9 +678,9 @@ class Entity:
680
678
  自分を中心に指定した座標にアイテムを使う
681
679
 
682
680
  Args:
683
- x (int): X座標。
684
- y (int): Y座標。
685
- z (int): Z座標。
681
+ x (int): X座標
682
+ y (int): Y座標
683
+ z (int): Z座標
686
684
  """
687
685
  self.client.sendCall(self.uuid, "useItemX", [x, y, z, "^"])
688
686
  return str_to_bool(self.client.result)
@@ -710,90 +708,150 @@ class Entity:
710
708
 
711
709
  def harvest(self) -> bool :
712
710
  """
713
- 自分の位置のブロックを収穫する。
711
+ 自分の位置のブロックを収穫する
714
712
  """
715
713
  self.client.sendCall(self.uuid, "digX", [0, 0, 0])
716
714
  return str_to_bool(self.client.result)
717
715
 
718
716
  def attack(self) -> bool :
719
717
  """
720
- 自分の前方を攻撃する。
718
+ 自分の前方を攻撃する
721
719
  """
722
720
  self.client.sendCall(self.uuid, "attack")
723
721
  return str_to_bool(self.client.result)
724
722
 
723
+ def plant(self) -> bool :
724
+ """
725
+ 自分の足元に植物を植える
726
+ """
727
+ self.client.sendCall(self.uuid, "plantX", [0, -1, 0, "^"])
728
+ return str_to_bool(self.client.result)
729
+
730
+ def plantX(self, x : int, y: int, z: int, cord: Coordinates = Coordinates.local) -> bool :
731
+ """
732
+ 指定した座標のブロックに植物を植える
733
+
734
+ Args:
735
+ x (int): X座標
736
+ y (int): Y座標
737
+ z (int): Z座標
738
+ cord (Coordinates): 座標の種類('', '^', '~')
739
+ """
740
+ self.client.sendCall(self.uuid, "plantX", [x, y, z, cord])
741
+ return str_to_bool(self.client.result)
742
+
743
+ def till(self) -> bool :
744
+ """
745
+ 自分の足元のブロックを耕す
746
+ """
747
+ self.client.sendCall(self.uuid, "tillX", [0, -1, 0, "^"])
748
+ return str_to_bool(self.client.result)
749
+
750
+ def tillX(self, x : int, y: int, z: int, cord: Coordinates = Coordinates.local) -> bool :
751
+ """
752
+ 指定した座標のブロックを耕す
753
+
754
+ Args:
755
+ x (int): X座標
756
+ y (int): Y座標
757
+ z (int): Z座標
758
+ cord (Coordinates): 座標の種類('', '^', '~')
759
+ """
760
+ self.client.sendCall(self.uuid, "tillX", [x, y, z, cord])
761
+ return str_to_bool(self.client.result)
762
+
763
+ def flatten(self) -> bool :
764
+ """
765
+ 自分の足元のブロックに平らにする
766
+ """
767
+ self.client.sendCall(self.uuid, "flattenX", [0, -1, 0, "^"])
768
+ return str_to_bool(self.client.result)
769
+
770
+ def flattenX(self, x : int, y: int, z: int, cord: Coordinates = Coordinates.local) -> bool :
771
+ """
772
+ 指定した座標のブロックを平らにする
773
+
774
+ Args:
775
+ x (int): X座標
776
+ y (int): Y座標
777
+ z (int): Z座標
778
+ cord (Coordinates): 座標の種類('', '^', '~')
779
+ """
780
+ self.client.sendCall(self.uuid, "flattenX", [x, y, z, cord])
781
+ return str_to_bool(self.client.result)
782
+
725
783
  def dig(self) -> bool :
726
784
  """
727
- 自分の前方のブロックを壊す。
785
+ 自分の前方のブロックを壊す
728
786
  """
729
787
  self.client.sendCall(self.uuid, "digFront")
730
788
  return str_to_bool(self.client.result)
731
789
 
732
790
  def digUp(self) -> bool :
733
791
  """
734
- 自分の真上のブロックを壊す。
792
+ 自分の真上のブロックを壊す
735
793
  """
736
794
  self.client.sendCall(self.uuid, "digUp")
737
795
  return str_to_bool(self.client.result)
738
796
 
739
797
  def digDown(self) -> bool :
740
798
  """
741
- 自分の真下のブロックを壊す。
799
+ 自分の真下のブロックを壊す
742
800
  """
743
801
  self.client.sendCall(self.uuid, "digDown")
744
802
  return str_to_bool(self.client.result)
745
803
 
746
- def digX(self, cord: Coordinates, x : int, y: int, z: int) -> bool :
804
+ def digX(self, x : int, y: int, z: int, cord: Coordinates = Coordinates.local) -> bool :
747
805
  """
748
- 指定した座標のブロックを壊す。
806
+ 指定した座標のブロックを壊す
749
807
 
750
808
  Args:
751
- cord (Coordinates): 座標の種類('', '^', '~')。
752
- x (int): X座標。
753
- y (int): Y座標。
754
- z (int): Z座標。
809
+ x (int): X座標
810
+ y (int): Y座標
811
+ z (int): Z座標
812
+ cord (Coordinates): 座標の種類('', '^', '~')
755
813
  """
756
814
  self.client.sendCall(self.uuid, "digX", [x, y, z, cord])
757
815
  return str_to_bool(self.client.result)
758
816
 
759
817
  def action(self) -> bool :
760
818
  """
761
- 自分の前方の装置を使う。
819
+ 自分の前方の装置を使う
762
820
  """
763
821
  self.client.sendCall(self.uuid, "actionFront")
764
822
  return str_to_bool(self.client.result)
765
823
 
766
824
  def actionUp(self) -> bool :
767
825
  """
768
- 自分の真上の装置を使う。
826
+ 自分の真上の装置を使う
769
827
  """
770
828
  self.client.sendCall(self.uuid, "actionUp")
771
829
  return str_to_bool(self.client.result)
772
830
 
773
831
  def actionDown(self) -> bool :
774
832
  """
775
- 自分の真下の装置を使う。
833
+ 自分の真下の装置を使う
776
834
  """
777
835
  self.client.sendCall(self.uuid, "actionDown")
778
836
  return str_to_bool(self.client.result)
779
837
 
780
838
  def setItem(self, slot: int, block: str) -> bool :
781
839
  """
782
- 自分のインベントリにアイテムを設定する。
840
+ 自分のインベントリにアイテムを設定する
783
841
 
784
842
  Args:
785
- slot (int): 設定するアイテムのスロット番号。
786
- block (str): 設定するブロックの種類。
843
+ slot (int): 設定するアイテムのスロット番号
844
+ block (str): 設定するブロックの種類
787
845
  """
788
846
  self.client.sendCall(self.uuid, "setItem", [slot, block])
789
847
  return str_to_bool(self.client.result)
790
848
 
791
849
  def getItem(self, slot: int) -> ItemStack :
792
850
  """
793
- 自分のインベントリからアイテムを取得する。
851
+ 自分のインベントリからアイテムを取得する
794
852
 
795
853
  Args:
796
- slot (int): 取得するアイテムのスロット番号。
854
+ slot (int): 取得するアイテムのスロット番号
797
855
  """
798
856
  self.client.sendCall(self.uuid, "getItem", [slot])
799
857
  itemStack = ItemStack(** json.loads(self.client.result))
@@ -801,55 +859,55 @@ class Entity:
801
859
 
802
860
  def swapItem(self, slot1: int, slot2: int) -> bool :
803
861
  """
804
- 自分のインベントリのアイテムを置き換える。
862
+ 自分のインベントリのアイテムを置き換える
805
863
  """
806
864
  self.client.sendCall(self.uuid, "swapItem", [slot1, slot2])
807
865
  return str_to_bool(self.client.result)
808
866
 
809
867
  def moveItem(self, slot1: int, slot2: int) -> bool :
810
868
  """
811
- 自分のインベントリのアイテムを移動させる。
869
+ 自分のインベントリのアイテムを移動させる
812
870
  """
813
871
  self.client.sendCall(self.uuid, "moveItem", [slot1, slot2])
814
872
  return str_to_bool(self.client.result)
815
873
 
816
874
  def dropItem(self, slot1: int) -> bool :
817
875
  """
818
- 自分のインベントリのアイテムを落とす。
876
+ 自分のインベントリのアイテムを落とす
819
877
  """
820
878
  self.client.sendCall(self.uuid, "dropItem", [slot1])
821
879
  return str_to_bool(self.client.result)
822
880
 
823
- def grabItem(self, slot: int) -> bool :
881
+ def selectItem(self, slot: int) -> bool :
824
882
  """
825
- 自分のインベントリのアイテムを手に持たせる。
883
+ 自分のインベントリのアイテムを手に持たせる
826
884
 
827
885
  Args:
828
- slot (int): アイテムを持たせたいスロットの番号。
886
+ slot (int): アイテムを持たせたいスロットの番号
829
887
  """
830
888
  self.client.sendCall(self.uuid, "grabItem", [slot])
831
889
  return str_to_bool(self.client.result)
832
890
 
833
891
  def say(self, message: str):
834
892
  """
835
- メッセージをチャットに送る。
893
+ メッセージをチャットに送る
836
894
 
837
895
  Args:
838
- message (str): エンティティがチャットで送信するメッセージの内容。
896
+ message (str): エンティティがチャットで送信するメッセージの内容
839
897
  """
840
898
  self.client.sendCall(self.uuid, "sendChat", [message])
841
899
 
842
- def inspectX(self, cord: Coordinates, x: int, y: int, z: int) -> Block :
900
+ def inspectX(self, x: int, y: int, z: int, cord: Coordinates = Coordinates.local) -> Block :
843
901
  """
844
- 指定された座標のブロックを調べる。
902
+ 指定された座標のブロックを調べる
845
903
 
846
904
  Args:
847
- cord (Coordinates): 座標の種類('', '^', '~')。
848
- x (int): X座標。
849
- y (int): Y座標。
850
- z (int): Z座標。
905
+ x (int): X座標
906
+ y (int): Y座標
907
+ z (int): Z座標
908
+ cord (Coordinates): 座標の種類('', '^', '~')
851
909
  Returns:
852
- Block: 調べたブロックの情報。
910
+ Block: 調べたブロックの情報
853
911
  """
854
912
  self.client.sendCall(self.uuid, "inspect", [x, y, z, cord])
855
913
  block = Block(** json.loads(self.client.result))
@@ -857,14 +915,14 @@ class Entity:
857
915
 
858
916
  def inspectHere(self, x: int, y: int, z: int) -> Block :
859
917
  """
860
- 自分を中心に指定された座標のブロックを調べる。
918
+ 自分を中心に指定された座標のブロックを調べる
861
919
 
862
920
  Args:
863
- x (int): X座標。
864
- y (int): Y座標。
865
- z (int): Z座標。
921
+ x (int): X座標
922
+ y (int): Y座標
923
+ z (int): Z座標
866
924
  Returns:
867
- Block: 調べたブロックの情報。
925
+ Block: 調べたブロックの情報
868
926
  """
869
927
  self.client.sendCall(self.uuid, "inspect", [x, y, z, "^"])
870
928
  block = Block(** json.loads(self.client.result))
@@ -872,10 +930,10 @@ class Entity:
872
930
 
873
931
  def inspect(self) -> Block :
874
932
  """
875
- 自分のいる場所のブロックを調べる。
933
+ 自分のいる場所のブロックを調べる
876
934
 
877
935
  Returns:
878
- Block: 調べたブロックの情報。
936
+ Block: 調べたブロックの情報
879
937
  """
880
938
  self.client.sendCall(self.uuid, "inspect", [0, 0, 0])
881
939
  block = Block(** json.loads(self.client.result))
@@ -883,10 +941,10 @@ class Entity:
883
941
 
884
942
  def inspectUp(self) -> Block :
885
943
  """
886
- 自分を真上のブロックを調べる。
944
+ 自分を真上のブロックを調べる
887
945
 
888
946
  Returns:
889
- Block: 調べたブロックの情報。
947
+ Block: 調べたブロックの情報
890
948
  """
891
949
  self.client.sendCall(self.uuid, "inspect", [0, 1, 0])
892
950
  block = Block(** json.loads(self.client.result))
@@ -894,10 +952,10 @@ class Entity:
894
952
 
895
953
  def inspectDown(self) -> Block :
896
954
  """
897
- 自分の足元のブロックを調べる。
955
+ 自分の足元のブロックを調べる
898
956
 
899
957
  Returns:
900
- Block: 調べたブロックの情報。
958
+ Block: 調べたブロックの情報
901
959
  """
902
960
  self.client.sendCall(self.uuid, "inspect", [0, -1, 0])
903
961
  block = Block(** json.loads(self.client.result))
@@ -905,9 +963,9 @@ class Entity:
905
963
 
906
964
  def getLocation(self) -> Location :
907
965
  """
908
- 自分の現在位置を調べる。
966
+ 自分の現在位置を調べる
909
967
  Returns:
910
- Location: 調べた位置情報。
968
+ Location: 調べた位置情報
911
969
  """
912
970
  self.client.sendCall(self.uuid, "getPosition")
913
971
  location = Location(** json.loads(self.client.result))
@@ -915,35 +973,35 @@ class Entity:
915
973
 
916
974
  def teleport(self, location: Location) :
917
975
  """
918
- 自分を指定されたワールド座標に移動する。
976
+ 自分を指定されたワールド座標に移動する
919
977
  Args:
920
- location (Location): 座標。
978
+ location (Location): 座標
921
979
  """
922
980
  self.client.sendCall(self.uuid, "teleport", [location.x, location.y, location.z, Coordinates.world])
923
981
 
924
982
  def isBlocked(self) -> bool :
925
983
  """
926
- 自分の前方にブロックがあるかどうか調べる。
984
+ 自分の前方にブロックがあるかどうか調べる
927
985
  Returns:
928
- bool: 調べた結果。
986
+ bool: 調べた結果
929
987
  """
930
988
  self.client.sendCall(self.uuid, "isBlockedFront")
931
989
  return str_to_bool(self.client.result)
932
990
 
933
991
  def isBlockedUp(self) -> bool :
934
992
  """
935
- 自分の真上にブロックがあるかどうか調べる。
993
+ 自分の真上にブロックがあるかどうか調べる
936
994
  Returns:
937
- bool: 調べた結果。
995
+ bool: 調べた結果
938
996
  """
939
997
  self.client.sendCall(self.uuid, "isBlockedUp")
940
998
  return str_to_bool(self.client.result)
941
999
 
942
1000
  def isBlockedDown(self) -> bool :
943
1001
  """
944
- 自分の真下にブロックがあるかどうか調べる。
1002
+ 自分の真下にブロックがあるかどうか調べる
945
1003
  Returns:
946
- bool: 調べた結果。
1004
+ bool: 調べた結果
947
1005
  """
948
1006
  self.client.sendCall(self.uuid, "isBlockedDown")
949
1007
  return str_to_bool(self.client.result)
@@ -951,91 +1009,90 @@ class Entity:
951
1009
 
952
1010
  def canDig(self) -> bool :
953
1011
  """
954
- 自分の前方のブロックが壊せるかどうか調べる。
1012
+ 自分の前方のブロックが壊せるかどうか調べる
955
1013
  Returns:
956
- bool: 調べた結果。
1014
+ bool: 調べた結果
957
1015
  """
958
1016
  self.client.sendCall(self.uuid, "isCanDigFront")
959
1017
  return str_to_bool(self.client.result)
960
1018
 
961
1019
  def canDigUp(self) -> bool :
962
1020
  """
963
- 自分の上のブロックが壊せるかどうか調べる。
1021
+ 自分の上のブロックが壊せるかどうか調べる
964
1022
  Returns:
965
- bool: 調べた結果。
1023
+ bool: 調べた結果
966
1024
  """
967
1025
  self.client.sendCall(self.uuid, "isCanDigUp")
968
1026
  return str_to_bool(self.client.result)
969
1027
 
970
1028
  def canDigDown(self) -> bool :
971
1029
  """
972
- 自分の下のブロックが壊せるかどうか調べる。
1030
+ 自分の下のブロックが壊せるかどうか調べる
973
1031
  Returns:
974
- bool: 調べた結果。
1032
+ bool: 調べた結果
975
1033
  """
976
1034
  self.client.sendCall(self.uuid, "isCanDigDown")
977
1035
  return str_to_bool(self.client.result)
978
1036
 
979
1037
  def lookAtTarget(self, uuid) -> bool:
980
1038
  """
981
- 指定されたエンティティを見る。
1039
+ 指定されたエンティティを見る
982
1040
  Args:
983
- uuid (str): エンティティのUUID
1041
+ uuid (str): エンティティのUUID
984
1042
  Returns:
985
- bool: 調べた結果。
1043
+ bool: 調べた結果
986
1044
  """
987
1045
  self.client.sendCall(self.uuid, "lookAtTarget", [uuid])
988
1046
  return str_to_bool(self.client.result)
989
1047
 
990
1048
  def getDistance(self) -> float :
991
1049
  """
992
- 自分と前方のターゲットとの距離を調べる。
1050
+ 自分と前方のターゲットとの距離を調べる
993
1051
  """
994
1052
  self.client.sendCall(self.uuid, "getTargetDistanceFront")
995
1053
  return self.client.result
996
1054
 
997
1055
  def getDistanceUp(self) -> float :
998
1056
  """
999
- 自分と真上のターゲットとの距離を調べる。
1057
+ 自分と真上のターゲットとの距離を調べる
1000
1058
  """
1001
1059
  self.client.sendCall(self.uuid, "getTargetDistanceUp")
1002
1060
  return float(self.client.result)
1003
1061
 
1004
1062
  def getDistanceDown(self) -> float :
1005
1063
  """
1006
- 自分と真下のターゲットとの距離を調べる。
1064
+ 自分と真下のターゲットとの距離を調べる
1007
1065
  """
1008
1066
  self.client.sendCall(self.uuid, "getTargetDistanceDown")
1009
1067
  return self.client.result
1010
1068
 
1011
1069
  def getDistanceTarget(self, uuid) -> float :
1012
1070
  """
1013
- 自分とターゲットとの距離を調べる。
1071
+ 自分とターゲットとの距離を調べる
1014
1072
  """
1015
1073
  self.client.sendCall(self.uuid, "getTargetDistance", [uuid])
1016
1074
  return self.client.result
1017
1075
 
1018
- def setBlock(self, cord: Coordinates, x: int, y: int, z: int, block: str, data: int = 0):
1076
+ def setBlock(self, x: int, y: int, z: int, block: str, data: int = 0):
1019
1077
  """
1020
- 指定された座標にブロックを設置する。(クリエイティブ)
1078
+ 指定された座標にブロックを設置する(クリエイティブ)
1021
1079
 
1022
1080
  Args:
1023
- cord (Coordinates): 座標の種類('', '^', '~')。
1024
- x (int): 絶対的なX座標。
1025
- y (int): 絶対的なY座標。
1026
- z (int): 絶対的なZ座標。
1027
- block (str): 設置するブロックの種類。
1081
+ x (int): 絶対的なX座標
1082
+ y (int): 絶対的なY座標
1083
+ z (int): 絶対的なZ座標
1084
+ block (str): 設置するブロックの種類
1028
1085
  """
1029
- self.client.sendCall(self.uuid, "setBlock", [x, y, z, cord, block, data])
1086
+ self.client.sendCall(self.uuid, "setBlock", [x, y, z, "", block, data])
1030
1087
 
1031
1088
  def getBlock(self, x: int, y: int, z: int) -> Block :
1032
1089
  """
1033
- 指定された座標のブロックを取得する。
1090
+ 指定された座標のブロックを取得する
1034
1091
 
1035
1092
  Args:
1036
- x (int): 絶対的なX座標。
1037
- y (int): 絶対的なY座標。
1038
- z (int): 絶対的なZ座標。
1093
+ x (int): 絶対的なX座標
1094
+ y (int): 絶対的なY座標
1095
+ z (int): 絶対的なZ座標
1039
1096
  """
1040
1097
  self.client.sendCall(self.uuid, "getBlock", [x, y, z])
1041
1098
  block = Block(** json.loads(self.client.result))
@@ -1043,7 +1100,7 @@ class Entity:
1043
1100
 
1044
1101
  def getBlockByColor(self, color: str) -> Block :
1045
1102
  """
1046
- 指定された色に近いブロックを取得する。
1103
+ 指定された色に近いブロックを取得する
1047
1104
 
1048
1105
  Args:
1049
1106
  color (str): ブロックの色(HexRGB形式)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2hackCraft2
3
- Version: 1.0.20
3
+ Version: 1.0.22
4
4
  Summary: These are APIs that connect to the hackCraft2 server from Python to manipulate pets.
5
5
  Home-page: https://pypi.org/project/py2hackCraft2/
6
6
  Author: Masafumi Terazono
@@ -5,7 +5,7 @@ long_description = (this_directory / "py2hackCraft/README.md").read_text()
5
5
 
6
6
  setup(
7
7
  name="py2hackCraft2",
8
- version="1.0.20",
8
+ version="1.0.22",
9
9
  packages=find_packages(),
10
10
  install_requires=[
11
11
  "websocket-client" # websocketライブラリの追加
File without changes
File without changes