py2hackCraft2 1.1.43__tar.gz → 1.1.45__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.4
2
2
  Name: py2hackCraft2
3
- Version: 1.1.43
3
+ Version: 1.1.45
4
4
  Summary: Python client library for hackCraft2
5
5
  Home-page: https://github.com/0x48lab/hackCraft2-python
6
6
  Author: masafumi_t
@@ -527,7 +527,7 @@ class Inventory:
527
527
  item = inventory.get_item(0)
528
528
  print(f"アイテム: {item.name}, 数量: {item.amount}")
529
529
  """
530
- self.client.send_call(self.entity_uuid, "getInventoryItem", [self.location.x, self.location.y, self.location.z, slot])
530
+ self.client.send_call(self.entity_uuid, "getInventoryItem", [self.location.x, self.location.y, self.location.z, slot, self.location.cord])
531
531
  item_stack = ItemStack(** json.loads(self.client.result))
532
532
  return item_stack
533
533
 
@@ -567,7 +567,7 @@ class Inventory:
567
567
  # スロット0と1のアイテムを入れ替え
568
568
  inventory.swap_items(0, 1)
569
569
  """
570
- self.client.send_call(self.entity_uuid, "swapInventoryItem", [self.location.x, self.location.y, self.location.z, slot1, slot2])
570
+ self.client.send_call(self.entity_uuid, "swapInventoryItem", [self.location.x, self.location.y, self.location.z, slot1, slot2, self.location.cord])
571
571
 
572
572
  def move_item(self, from_slot: int, to_slot: int):
573
573
  """
@@ -583,7 +583,7 @@ class Inventory:
583
583
  # スロット0のアイテムをスロット5に移動
584
584
  inventory.move_item(0, 5)
585
585
  """
586
- self.client.send_call(self.entity_uuid, "moveInventoryItem", [self.location.x, self.location.y, self.location.z, from_slot, to_slot])
586
+ self.client.send_call(self.entity_uuid, "moveInventoryItem", [self.location.x, self.location.y, self.location.z, from_slot, to_slot, self.location.cord])
587
587
 
588
588
  def retrieve_to_self(self, from_slot: int, to_slot: int):
589
589
  """
@@ -599,7 +599,7 @@ class Inventory:
599
599
  # チェストのスロット0のアイテムを自分のスロット5に取り出す
600
600
  inventory.retrieve_from_self(0, 5)
601
601
  """
602
- self.client.send_call(self.entity_uuid, "retrieveInventoryItem", [self.location.x, self.location.y, self.location.z, to_slot, from_slot])
602
+ self.client.send_call(self.entity_uuid, "retrieveInventoryItem", [self.location.x, self.location.y, self.location.z, to_slot, from_slot, self.location.cord])
603
603
 
604
604
  def store_from_self(self, from_slot: int, to_slot: int):
605
605
  """
@@ -615,7 +615,7 @@ class Inventory:
615
615
  # 自分のスロット0のアイテムをチェストのスロット5に格納
616
616
  inventory.store_to_self(0, 5)
617
617
  """
618
- self.client.send_call(self.entity_uuid, "storeInventoryItem", [self.location.x, self.location.y, self.location.z, from_slot, to_slot])
618
+ self.client.send_call(self.entity_uuid, "storeInventoryItem", [self.location.x, self.location.y, self.location.z, from_slot, to_slot, self.location.cord])
619
619
 
620
620
  class Volume:
621
621
  """
@@ -1358,6 +1358,156 @@ class Entity:
1358
1358
  self.client.send_call(self.uuid, "digX", [0, -1, 0])
1359
1359
  return str_to_bool(self.client.result)
1360
1360
 
1361
+ # ===== Sign Operations =====
1362
+
1363
+ def write_sign(self, text) -> bool:
1364
+ """
1365
+ 自分の前方の看板にテキストを書き込む
1366
+
1367
+ Args:
1368
+ text: 書き込むテキスト。文字列またはリスト(各要素が各行になる、最大4行)
1369
+
1370
+ Returns:
1371
+ bool: 操作が成功した場合はTrue、失敗した場合はFalse
1372
+
1373
+ Examples:
1374
+ 文字列で書き込む::
1375
+
1376
+ entity.write_sign("Hello World")
1377
+
1378
+ 複数行を書き込む::
1379
+
1380
+ entity.write_sign(["1行目", "2行目", "3行目", "4行目"])
1381
+ """
1382
+ if isinstance(text, list):
1383
+ text = '\n'.join(str(line) for line in text[:4])
1384
+ self.client.send_call(self.uuid, "setSign", [str(text), "front"])
1385
+ return str_to_bool(self.client.result)
1386
+
1387
+ def write_sign_up(self, text) -> bool:
1388
+ """
1389
+ 自分の真上の看板にテキストを書き込む
1390
+
1391
+ Args:
1392
+ text: 書き込むテキスト。文字列またはリスト(各要素が各行になる、最大4行)
1393
+
1394
+ Returns:
1395
+ bool: 操作が成功した場合はTrue、失敗した場合はFalse
1396
+ """
1397
+ if isinstance(text, list):
1398
+ text = '\n'.join(str(line) for line in text[:4])
1399
+ self.client.send_call(self.uuid, "setSign", [str(text), "up"])
1400
+ return str_to_bool(self.client.result)
1401
+
1402
+ def write_sign_down(self, text) -> bool:
1403
+ """
1404
+ 自分の真下の看板にテキストを書き込む
1405
+
1406
+ Args:
1407
+ text: 書き込むテキスト。文字列またはリスト(各要素が各行になる、最大4行)
1408
+
1409
+ Returns:
1410
+ bool: 操作が成功した場合はTrue、失敗した場合はFalse
1411
+ """
1412
+ if isinstance(text, list):
1413
+ text = '\n'.join(str(line) for line in text[:4])
1414
+ self.client.send_call(self.uuid, "setSign", [str(text), "down"])
1415
+ return str_to_bool(self.client.result)
1416
+
1417
+ def write_sign_at(self, loc: Location, text) -> bool:
1418
+ """
1419
+ 指定した座標の看板にテキストを書き込む
1420
+
1421
+ Args:
1422
+ loc (Location): 座標情報(LocationFactory.absolute/relative/localで生成)
1423
+ text: 書き込むテキスト。文字列またはリスト(各要素が各行になる、最大4行)
1424
+
1425
+ Returns:
1426
+ bool: 操作が成功した場合はTrue、失敗した場合はFalse
1427
+
1428
+ Examples:
1429
+ 相対座標で指定::
1430
+
1431
+ loc = LocationFactory.relative(0, 1, 0) # 1ブロック上
1432
+ entity.write_sign_at(loc, "相対座標のメッセージ")
1433
+
1434
+ ローカル座標で指定::
1435
+
1436
+ loc = LocationFactory.local(0, 0, 1) # 前方1ブロック
1437
+ entity.write_sign_at(loc, "ローカル座標のメッセージ")
1438
+
1439
+ 複数行を書き込む::
1440
+
1441
+ loc = LocationFactory.local(0, 0, 1)
1442
+ entity.write_sign_at(loc, ["1行目", "2行目", "3行目"])
1443
+ """
1444
+ if isinstance(text, list):
1445
+ text = '\n'.join(str(line) for line in text[:4])
1446
+ self.client.send_call(self.uuid, "setSignX", [str(text), loc.x, loc.y, loc.z, loc.cord])
1447
+ return str_to_bool(self.client.result)
1448
+
1449
+ def read_sign(self) -> str:
1450
+ """
1451
+ 自分の前方の看板のテキストを読み取る
1452
+
1453
+ Returns:
1454
+ str: 看板のテキスト(複数行の場合は改行で区切られた文字列)、看板がない場合は空文字列
1455
+
1456
+ Examples:
1457
+ テキストを読み取る::
1458
+
1459
+ text = entity.read_sign()
1460
+ print(text) # "1行目\\n2行目\\n..."
1461
+ """
1462
+ self.client.send_call(self.uuid, "getSign", ["front"])
1463
+ return self.client.result if self.client.result else ""
1464
+
1465
+ def read_sign_up(self) -> str:
1466
+ """
1467
+ 自分の真上の看板のテキストを読み取る
1468
+
1469
+ Returns:
1470
+ str: 看板のテキスト(複数行の場合は改行で区切られた文字列)、看板がない場合は空文字列
1471
+ """
1472
+ self.client.send_call(self.uuid, "getSign", ["up"])
1473
+ return self.client.result if self.client.result else ""
1474
+
1475
+ def read_sign_down(self) -> str:
1476
+ """
1477
+ 自分の真下の看板のテキストを読み取る
1478
+
1479
+ Returns:
1480
+ str: 看板のテキスト(複数行の場合は改行で区切られた文字列)、看板がない場合は空文字列
1481
+ """
1482
+ self.client.send_call(self.uuid, "getSign", ["down"])
1483
+ return self.client.result if self.client.result else ""
1484
+
1485
+ def read_sign_at(self, loc: Location) -> str:
1486
+ """
1487
+ 指定した座標の看板のテキストを読み取る
1488
+
1489
+ Args:
1490
+ loc (Location): 座標情報(LocationFactory.absolute/relative/localで生成)
1491
+
1492
+ Returns:
1493
+ str: 看板のテキスト(複数行の場合は改行で区切られた文字列)、看板がない場合は空文字列
1494
+
1495
+ Examples:
1496
+ 相対座標で指定::
1497
+
1498
+ loc = LocationFactory.relative(0, 1, 0) # 1ブロック上
1499
+ text = entity.read_sign_at(loc)
1500
+
1501
+ ローカル座標で指定::
1502
+
1503
+ loc = LocationFactory.local(0, 0, 1) # 前方1ブロック
1504
+ text = entity.read_sign_at(loc)
1505
+ """
1506
+ self.client.send_call(self.uuid, "getSignX", [loc.x, loc.y, loc.z, loc.cord])
1507
+ return self.client.result if self.client.result else ""
1508
+
1509
+ # ===== End Sign Operations =====
1510
+
1361
1511
  def attack(self) -> bool:
1362
1512
  """
1363
1513
  自分の前方を攻撃する
@@ -2126,7 +2276,7 @@ class Entity:
2126
2276
  def livestock_herd(self, animal_uuid: str, x: float, y: float, z: float, cord: str = "^", speed: float = 1.0) -> None:
2127
2277
  """
2128
2278
  動物を指定座標に誘導
2129
-
2279
+
2130
2280
  Args:
2131
2281
  animal_uuid (str): 動物のUUID
2132
2282
  x (float): 目標X座標
@@ -2134,11 +2284,11 @@ class Entity:
2134
2284
  z (float): 目標Z座標
2135
2285
  cord (str): 座標系("": 絶対座標, "~": 相対座標, "^": ローカル座標、デフォルト: "^")
2136
2286
  speed (float): 移動速度(0.5-2.0、デフォルト1.0)
2137
-
2287
+
2138
2288
  Example:
2139
2289
  >>> entity.livestock_herd(cow_uuid, 100, 64, 200, "^", 1.0)
2140
2290
  """
2141
- self.client.send_call(animal_uuid, "livestockHerd", [x, y, z, cord, speed])
2291
+ self.client.send_call(self.uuid, "livestockHerd", [animal_uuid, x, y, z, cord, speed])
2142
2292
  result = json.loads(self.client.result)
2143
2293
  if not result.get('success', False):
2144
2294
  raise Exception(f"Herd operation failed: {result.get('message', 'Unknown error')}")
@@ -2198,7 +2348,7 @@ class Entity:
2198
2348
  >>> except Exception as e:
2199
2349
  >>> print(f"Cannot shear: {e}")
2200
2350
  """
2201
- self.client.send_call(sheep_uuid, "livestockShear", [])
2351
+ self.client.send_call(self.uuid, "livestockShear", [sheep_uuid])
2202
2352
  result = json.loads(self.client.result)
2203
2353
  if not result.get('success', False):
2204
2354
  raise Exception(f"Shear operation failed: {result.get('message', 'Unknown error')}")
@@ -2224,7 +2374,7 @@ class Entity:
2224
2374
  >>> except Exception as e:
2225
2375
  >>> print(f"Cannot milk: {e}")
2226
2376
  """
2227
- self.client.send_call(cow_uuid, "livestockMilk", [])
2377
+ self.client.send_call(self.uuid, "livestockMilk", [cow_uuid])
2228
2378
  result = json.loads(self.client.result)
2229
2379
  if not result.get('success', False):
2230
2380
  raise Exception(f"Milk operation failed: {result.get('message', 'Unknown error')}")
@@ -2241,7 +2391,7 @@ class Entity:
2241
2391
  Example:
2242
2392
  >>> entity.livestock_feed(cow_uuid, "wheat")
2243
2393
  """
2244
- self.client.send_call(animal_uuid, "livestockFeed", [food_type])
2394
+ self.client.send_call(self.uuid, "livestockFeed", [animal_uuid, food_type])
2245
2395
  result = json.loads(self.client.result)
2246
2396
  if not result.get('success', False):
2247
2397
  raise Exception(f"Feed operation failed: {result.get('message', 'Unknown error')}")
@@ -2261,7 +2411,7 @@ class Entity:
2261
2411
  >>> print(f"Health: {info['health']}/{info['maxHealth']}")
2262
2412
  >>> print(f"Can breed: {info['canBreed']}")
2263
2413
  """
2264
- self.client.send_call(animal_uuid, "livestockInfo", [])
2414
+ self.client.send_call(self.uuid, "livestockInfo", [animal_uuid])
2265
2415
  result = json.loads(self.client.result)
2266
2416
  if not result.get('success', False):
2267
2417
  raise Exception(f"Get info operation failed: {result.get('message', 'Unknown error')}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: py2hackCraft2
3
- Version: 1.1.43
3
+ Version: 1.1.45
4
4
  Summary: Python client library for hackCraft2
5
5
  Home-page: https://github.com/0x48lab/hackCraft2-python
6
6
  Author: masafumi_t
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="py2hackCraft2",
5
- version="1.1.43",
5
+ version="v1.1.45",
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  "websocket-client>=1.6.0",
File without changes
File without changes