Скрипт:
import sys
from time import sleep
import minescript # minescript все еще нужен для других функций
from lib_java import JavaClass, java_class_map, java_member_map

Mojang -> Intermediary mappings

mc_class_name = minescript.version_info().minecraft_class_name
if mc_class_name == "net.minecraft.class_310": # 1.16.5, 1.17.1, 1.18.2, 1.19.2 uses this for MinecraftClient
java_class_map.update({
"net.minecraft.client.Minecraft": "net.minecraft.class_310",
"net.minecraft.world.inventory.ClickType": "net.minecraft.class_1713",
})
java_member_map.update({
"getInstance": "method_1551",
"player": "field_1724",
"screen": "field_1755",
"gameMode": "field_1761",
"handleInventoryMouseClick": "method_2906",
"getMenu": "method_17577",
"containerId": "field_7763",
"keyPressed": "method_25404",
})
elif mc_class_name == "net.minecraft.client.Minecraft":
pass

Minecraft = JavaClass("net.minecraft.client.Minecraft")
ClickType = JavaClass("net.minecraft.world.inventory.ClickType")

minecraft = Minecraft.getInstance()

def wait_screen(timeout_ms: int = 500) -> bool:
"""
Waits for the screen name to become available within a specified period.
Args:
timeout_ms (int): Maximum time to wait in milliseconds.
Returns:
bool: True if a screen name is detected within the wait period, False otherwise.
"""
steps = timeout_ms // 50
for _ in range(steps):
if minescript.screen_name() is not None:
return True
sleep(0.05)
return False

def open_targeted_chest() -> bool:
"""
Attempts to open the chest block currently targeted by the player.
Returns:
bool: True if a chest was successfully opened, False otherwise.
"""
block = minescript.player_get_targeted_block()
if block is None or "chest" not in block.type.lower():
return False

Generated code
minescript.press_key_bind("key.use", True)
r = wait_screen()
minescript.press_key_bind("key.use", False)
if not r:
    return False

return True


def take_items(slots_arg: list[int] | str) -> bool:
"""
Transfers items from the specified inventory slots to the player's inventory using quick move.
Args:
slots_arg (list[int] | str): A list of slot indices to move items from,
or "all" to move items from standard chest slots (0-26).
Returns:
bool: True if the operation was performed, False if no screen is open or other error.
"""
screen = minecraft.screen
if screen is None:
return False

Generated code
container_menu = screen.getMenu()
if container_menu is None:
    return False

if container_menu.containerId is None:
    return False # Or handle as an error if needed, but for silence, just fail.

mouse_button = 0

slots_to_process: list[int]
if isinstance(slots_arg, str) and slots_arg.lower() == "all":
    slots_to_process = list(range(27))
elif isinstance(slots_arg, list):
    slots_to_process = slots_arg
else:
    return False # Invalid argument type

for slot_index in slots_to_process:
    try:
        slot_id = int(slot_index)
        if slot_id < 0:
            continue # Skip invalid slot index
    except ValueError:
        continue # Skip non-integer slot index
    
    minecraft.gameMode.handleInventoryMouseClick(
        container_menu.containerId,
        slot_id,
        mouse_button,
        ClickType.QUICK_MOVE,
        minecraft.player,
    )
    sleep(0.01)

return True
IGNORE_WHEN_COPYING_START
content_copy
download
Use code with caution.
IGNORE_WHEN_COPYING_END

def close_chest():
"""
Closes the currently open chest GUI in Minecraft by simulating an Escape key press.
"""
screen = minecraft.screen
if screen is not None:
screen.keyPressed(256, 1, 0)
for _ in range(10): # Wait a moment for screen to actually close
if minecraft.screen is None:
break
sleep(0.05)

def main():
if len(sys.argv) < 2:
# No echo for usage instructions
return

Generated code
slots_input_args = sys.argv[1:]
slots_to_action: list[int] | str

if len(slots_input_args) == 1 and slots_input_args[0].lower() == "all":
    slots_to_action = "all"
else:
    try:
        slots_to_action = [int(slot) for slot in slots_input_args]
    except ValueError:
        # No echo for error message
        return

if not open_targeted_chest():
    return

sleep(0.2) 

if not take_items(slots_to_action):
    close_chest() # Attempt to close chest even if taking items failed
    return

sleep(0.2)
close_chest()
IGNORE_WHEN_COPYING_START
content_copy
download
Use code with caution.
IGNORE_WHEN_COPYING_END

if name == "main":
main()
Я хочу использовать этот скрипт как функцию в другом скрипте, импортировав его туда. Проблема заключается в том, что этот скрипт принимает sys.argv для работы. Как мне передать значения для этого скрипта при вызове из другого скрипта?