import os
import fileinput

def replace_in_file(file_path):
    with fileinput.FileInput(file_path, inplace=True) as file:
        for line in file:
            line = line.replace("set_block_property", "set_block_state")
            line = line.replace("block_property", "block_state")
            line = line.replace("has_block_property", "has_block_state")
            line = line.replace("properties", "states")
            print(line, end='')

def find_and_replace_json_files(directory):
    for root, _, files in os.walk(directory):
        for file_name in files:
            if file_name.endswith(".json"):
                file_path = os.path.join(root, file_name)
                replace_in_file(file_path)
                print(f'Replaced in: {file_name}')

if __name__ == "__main__":
    folder_path = input("Please enter the location of the 'blocks' folder: ")
    
    if os.path.exists(folder_path):
        find_and_replace_json_files(folder_path)
        print("Replacement completed successfully.")
        input("Press Enter to exit")
    else:
        print("The specified folder does not exist.")
