py2hackCraft2 1.1.42__tar.gz → 1.1.44__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.42
3
+ Version: 1.1.44
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
  """
@@ -2054,3 +2054,215 @@ class Entity:
2054
2054
  result = json.loads(self.client.result)
2055
2055
 
2056
2056
  return result
2057
+
2058
+ # ===== Livestock Methods =====
2059
+
2060
+ def livestock_count_nearby(self, animal_type: str = "ALL", radius: float = 50.0) -> int:
2061
+ """
2062
+ 近くの動物を数える
2063
+
2064
+ Args:
2065
+ animal_type (str): 動物種別(COW, PIG, SHEEP, CHICKEN, RABBIT, HORSE, ALL)
2066
+ radius (float): 検索半径(ブロック数)
2067
+
2068
+ Returns:
2069
+ int: 動物の数
2070
+
2071
+ Example:
2072
+ >>> count = entity.livestock_count_nearby("COW", 50)
2073
+ >>> print(f"Found {count} cows")
2074
+ """
2075
+ self.client.send_call(self.uuid, "livestockCountNearby", [animal_type, radius])
2076
+ result = json.loads(self.client.result)
2077
+ if not result.get('success', False):
2078
+ raise Exception(f"Livestock operation failed: {result.get('message', 'Unknown error')}")
2079
+ return result.get('data', {}).get('count', 0)
2080
+
2081
+ def livestock_get_nearest_uuid(self, animal_type: str = "ALL", radius: float = 50.0) -> Optional[str]:
2082
+ """
2083
+ 最も近い動物のUUIDを取得
2084
+
2085
+ Args:
2086
+ animal_type (str): 動物種別(COW, PIG, SHEEP, CHICKEN, RABBIT, HORSE, ALL)
2087
+ radius (float): 検索半径(ブロック数)
2088
+
2089
+ Returns:
2090
+ Optional[str]: 動物のUUID(見つからない場合はNone)
2091
+
2092
+ Example:
2093
+ >>> cow_uuid = entity.livestock_get_nearest_uuid("COW", 50)
2094
+ >>> if cow_uuid:
2095
+ >>> print(f"Found cow: {cow_uuid}")
2096
+ """
2097
+ self.client.send_call(self.uuid, "livestockGetNearestUuid", [animal_type, radius])
2098
+ result = json.loads(self.client.result)
2099
+ if not result.get('success', False):
2100
+ raise Exception(f"Livestock operation failed: {result.get('message', 'Unknown error')}")
2101
+ uuid = result.get('data', {}).get('uuid')
2102
+ return uuid if uuid else None
2103
+
2104
+ def livestock_find_nearby(self, animal_type: str = "ALL", radius: float = 50.0) -> list:
2105
+ """
2106
+ 近くの動物を詳細情報付きで検索
2107
+
2108
+ Args:
2109
+ animal_type (str): 動物種別(COW, PIG, SHEEP, CHICKEN, RABBIT, HORSE, ALL)
2110
+ radius (float): 検索半径(ブロック数)
2111
+
2112
+ Returns:
2113
+ list: 動物情報の辞書リスト
2114
+
2115
+ Example:
2116
+ >>> animals = entity.livestock_find_nearby("SHEEP", 30)
2117
+ >>> for animal in animals:
2118
+ >>> print(f"{animal['animalType']} at distance {animal['distance']}")
2119
+ """
2120
+ self.client.send_call(self.uuid, "livestockFindNearby", [animal_type, radius])
2121
+ result = json.loads(self.client.result)
2122
+ if not result.get('success', False):
2123
+ raise Exception(f"Livestock operation failed: {result.get('message', 'Unknown error')}")
2124
+ return result.get('data', {}).get('entities', [])
2125
+
2126
+ def livestock_herd(self, animal_uuid: str, x: float, y: float, z: float, cord: str = "^", speed: float = 1.0) -> None:
2127
+ """
2128
+ 動物を指定座標に誘導
2129
+
2130
+ Args:
2131
+ animal_uuid (str): 動物のUUID
2132
+ x (float): 目標X座標
2133
+ y (float): 目標Y座標
2134
+ z (float): 目標Z座標
2135
+ cord (str): 座標系("": 絶対座標, "~": 相対座標, "^": ローカル座標、デフォルト: "^")
2136
+ speed (float): 移動速度(0.5-2.0、デフォルト1.0)
2137
+
2138
+ Example:
2139
+ >>> entity.livestock_herd(cow_uuid, 100, 64, 200, "^", 1.0)
2140
+ """
2141
+ self.client.send_call(self.uuid, "livestockHerd", [animal_uuid, x, y, z, cord, speed])
2142
+ result = json.loads(self.client.result)
2143
+ if not result.get('success', False):
2144
+ raise Exception(f"Herd operation failed: {result.get('message', 'Unknown error')}")
2145
+
2146
+ def livestock_herd_all_nearby(
2147
+ self,
2148
+ animal_type: str,
2149
+ radius: float,
2150
+ x: float,
2151
+ y: float,
2152
+ z: float,
2153
+ cord: str = "^",
2154
+ speed: float = 1.0
2155
+ ) -> int:
2156
+ """
2157
+ 近くの動物すべてを指定座標に誘導
2158
+
2159
+ Args:
2160
+ animal_type (str): 動物種別(COW, PIG, SHEEP, CHICKEN, RABBIT, HORSE, ALL)
2161
+ radius (float): 検索半径(ブロック数)
2162
+ x (float): 目標X座標
2163
+ y (float): 目標Y座標
2164
+ z (float): 目標Z座標
2165
+ cord (str): 座標系("": 絶対座標, "~": 相対座標, "^": ローカル座標、デフォルト: "^")
2166
+ speed (float): 移動速度(0.5-2.0、デフォルト1.0)
2167
+
2168
+ Returns:
2169
+ int: 誘導した動物の数
2170
+
2171
+ Example:
2172
+ >>> count = entity.livestock_herd_all_nearby("COW", 50, 100, 64, 200)
2173
+ >>> print(f"Herded {count} cows")
2174
+ """
2175
+ self.client.send_call(self.uuid, "livestockHerdAllNearby", [animal_type, radius, x, y, z, cord, speed])
2176
+ result = json.loads(self.client.result)
2177
+ if not result.get('success', False):
2178
+ raise Exception(f"Herd all operation failed: {result.get('message', 'Unknown error')}")
2179
+ return result.get('data', {}).get('count', 0)
2180
+
2181
+ def livestock_shear(self, sheep_uuid: str) -> dict:
2182
+ """
2183
+ 羊の毛を刈る
2184
+
2185
+ Args:
2186
+ sheep_uuid (str): 羊のUUID
2187
+
2188
+ Returns:
2189
+ dict: 羊毛情報 {wool, color, amount}
2190
+
2191
+ Raises:
2192
+ Exception: 羊毛が生えていない、または羊以外の動物の場合
2193
+
2194
+ Example:
2195
+ >>> try:
2196
+ >>> result = entity.livestock_shear(sheep_uuid)
2197
+ >>> print(f"Got {result['amount']} {result['color']} wool")
2198
+ >>> except Exception as e:
2199
+ >>> print(f"Cannot shear: {e}")
2200
+ """
2201
+ self.client.send_call(self.uuid, "livestockShear", [sheep_uuid])
2202
+ result = json.loads(self.client.result)
2203
+ if not result.get('success', False):
2204
+ raise Exception(f"Shear operation failed: {result.get('message', 'Unknown error')}")
2205
+ return result.get('data', {})
2206
+
2207
+ def livestock_milk(self, cow_uuid: str) -> dict:
2208
+ """
2209
+ 牛のミルクを搾る
2210
+
2211
+ Args:
2212
+ cow_uuid (str): 牛のUUID
2213
+
2214
+ Returns:
2215
+ dict: ミルク情報 {milk, amount}
2216
+
2217
+ Raises:
2218
+ Exception: 牛以外の動物の場合
2219
+
2220
+ Example:
2221
+ >>> try:
2222
+ >>> result = entity.livestock_milk(cow_uuid)
2223
+ >>> print(f"Got {result['amount']} milk bucket")
2224
+ >>> except Exception as e:
2225
+ >>> print(f"Cannot milk: {e}")
2226
+ """
2227
+ self.client.send_call(self.uuid, "livestockMilk", [cow_uuid])
2228
+ result = json.loads(self.client.result)
2229
+ if not result.get('success', False):
2230
+ raise Exception(f"Milk operation failed: {result.get('message', 'Unknown error')}")
2231
+ return result.get('data', {})
2232
+
2233
+ def livestock_feed(self, animal_uuid: str, food_type: str = "wheat") -> None:
2234
+ """
2235
+ 動物に餌をやる
2236
+
2237
+ Args:
2238
+ animal_uuid (str): 動物のUUID
2239
+ food_type (str): 餌種別(wheat, carrot, seeds, beetroot)
2240
+
2241
+ Example:
2242
+ >>> entity.livestock_feed(cow_uuid, "wheat")
2243
+ """
2244
+ self.client.send_call(self.uuid, "livestockFeed", [animal_uuid, food_type])
2245
+ result = json.loads(self.client.result)
2246
+ if not result.get('success', False):
2247
+ raise Exception(f"Feed operation failed: {result.get('message', 'Unknown error')}")
2248
+
2249
+ def livestock_get_info(self, animal_uuid: str) -> dict:
2250
+ """
2251
+ 動物の詳細情報を取得
2252
+
2253
+ Args:
2254
+ animal_uuid (str): 動物のUUID
2255
+
2256
+ Returns:
2257
+ dict: 動物の詳細情報
2258
+
2259
+ Example:
2260
+ >>> info = entity.livestock_get_info(cow_uuid)
2261
+ >>> print(f"Health: {info['health']}/{info['maxHealth']}")
2262
+ >>> print(f"Can breed: {info['canBreed']}")
2263
+ """
2264
+ self.client.send_call(self.uuid, "livestockInfo", [animal_uuid])
2265
+ result = json.loads(self.client.result)
2266
+ if not result.get('success', False):
2267
+ raise Exception(f"Get info operation failed: {result.get('message', 'Unknown error')}")
2268
+ return result.get('data', {}).get('entityInfo', {})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: py2hackCraft2
3
- Version: 1.1.42
3
+ Version: 1.1.44
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.42",
5
+ version="v1.1.44",
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  "websocket-client>=1.6.0",
File without changes
File without changes