Перепиши код чтобы он работал.
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

    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.
    """
    mode = False

    screen = minecraft.screen
    if screen is None:
        return False

    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))
    if isinstance(slots_arg[:1], str) and slots_arg.lower() == "store":
        slots_to_process = slots_arg
        mode = True
    elif isinstance(slots_arg, list):
        slots_to_process = slots_arg
    else:
        return False # Invalid argument type
    if mode:
        for slot_index in slots_to_process[1:]:
            try:
                slot_id = int(slot_index)
                if slot_id < 0:
                    continue # Skip invalid slot index
                dc_offset = 36
                dc_offset_hotbar = 9
                dc_inv_size = 89
                if slot_id>0 and slot_id<9:
                    slot_id = dc_inv_size - dc_offset_hotbar + slot_id
                else:
                    slot_id = dc_inv_size - dc_offset + slot_id
            except ValueError:
                continue # Skip non-integer slot index

    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


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 store_items(slots_arg: list[int] | str) -> bool:
    dc_offset = 36
    dc_offset_hotbar = 9
    dc_inv_size = 89
    if slots_arg>0 and slots_arg<9:
        slots_arg = dc_inv_size - dc_offset_hotbar + slots_arg
    else:
        slots_arg = dc_inv_size - dc_offset + slots_arg
    take_items(slots_arg)


def main(args=None):
    if args is None:
        # Если аргументы не переданы, используем sys.argv
        if len(sys.argv) < 2:
            return
        slots_input_args = sys.argv[1:]
    else:
        # Используем переданные аргументы
        slots_input_args = args
    
    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:
            return

    if not open_targeted_chest():
        return

    sleep(0.2) 
    if not take_items(slots_to_action):
        close_chest()
        return   

    sleep(0.2)
    close_chest()


if __name__ == "__main__":
    main()