|
| 1 | +import os |
| 2 | +import shutil |
| 3 | +import tkinter as tk |
| 4 | +from tkinter import filedialog, messagebox |
| 5 | +from PIL import Image, ImageTk |
| 6 | + |
| 7 | + |
| 8 | +def copy_mods(): |
| 9 | + selected_mods_folder = filedialog.askdirectory(title="Select folder with mods") |
| 10 | + if not selected_mods_folder: |
| 11 | + return |
| 12 | + |
| 13 | + mc_mods_folder = os.path.join(os.getenv('APPDATA'), '.minecraft', 'mods') |
| 14 | + |
| 15 | + if os.path.exists(mc_mods_folder): |
| 16 | + shutil.rmtree(mc_mods_folder) |
| 17 | + |
| 18 | + shutil.copytree(selected_mods_folder, mc_mods_folder) |
| 19 | + messagebox.showinfo("Success", "Mods have been copied!") |
| 20 | + |
| 21 | + |
| 22 | +def copy_saves(): |
| 23 | + selected_saves_folder = filedialog.askdirectory(title="Select folder with saves") |
| 24 | + if not selected_saves_folder: |
| 25 | + return |
| 26 | + |
| 27 | + mc_saves_folder = os.path.join(os.getenv('APPDATA'), '.minecraft', 'saves') |
| 28 | + |
| 29 | + if os.path.exists(mc_saves_folder): |
| 30 | + shutil.rmtree(mc_saves_folder) |
| 31 | + |
| 32 | + shutil.copytree(selected_saves_folder, mc_saves_folder) |
| 33 | + messagebox.showinfo("Success", "Saves have been copied!") |
| 34 | + |
| 35 | + |
| 36 | +def copy_saves_to_destination(): |
| 37 | + selected_destination_folder = filedialog.askdirectory(title="Select destination folder for saves") |
| 38 | + if not selected_destination_folder: |
| 39 | + return |
| 40 | + |
| 41 | + mc_saves_folder = os.path.join(os.getenv('APPDATA'), '.minecraft', 'saves') |
| 42 | + |
| 43 | + if not os.path.exists(mc_saves_folder): |
| 44 | + messagebox.showerror("Error", "No saves found in .minecraft/saves folder.") |
| 45 | + return |
| 46 | + |
| 47 | + for save_folder in os.listdir(mc_saves_folder): |
| 48 | + source_save_path = os.path.join(mc_saves_folder, save_folder) |
| 49 | + destination_save_path = os.path.join(selected_destination_folder, save_folder) |
| 50 | + |
| 51 | + if os.path.exists(destination_save_path): |
| 52 | + shutil.rmtree(destination_save_path) |
| 53 | + |
| 54 | + shutil.copytree(source_save_path, destination_save_path) |
| 55 | + |
| 56 | + messagebox.showinfo("Success", "Saves have been copied to the destination folder!") |
| 57 | + |
| 58 | + |
| 59 | +def main(): |
| 60 | + root = tk.Tk() |
| 61 | + root.title("Copy Mods and Saves to Minecraft") |
| 62 | + root.geometry("400x250") |
| 63 | + |
| 64 | + root.iconbitmap("icon.ico") |
| 65 | + |
| 66 | + background_image = Image.open("background.png") |
| 67 | + background_imageTk = ImageTk.PhotoImage(background_image) |
| 68 | + |
| 69 | + canvas = tk.Canvas(root, width=400, height=250) |
| 70 | + canvas.pack() |
| 71 | + canvas.create_image(0, 0, anchor=tk.NW, image=background_imageTk) |
| 72 | + |
| 73 | + label_mods = tk.Label(root, text="Choose modpack to load.", bg='gray', fg='white') |
| 74 | + label_mods.place(relx=0.5, rely=0.2, anchor=tk.CENTER) |
| 75 | + |
| 76 | + button_mods = tk.Button(root, text="Load mods", command=copy_mods, bg='gray', fg='white') |
| 77 | + button_mods.place(relx=0.5, rely=0.3, anchor=tk.CENTER) |
| 78 | + |
| 79 | + label_saves = tk.Label(root, text="Choose save folder for modpack.", bg='gray', fg='white') |
| 80 | + label_saves.place(relx=0.5, rely=0.5, anchor=tk.CENTER) |
| 81 | + |
| 82 | + button_saves = tk.Button(root, text="Load saves", command=copy_saves, bg='gray', fg='white') |
| 83 | + button_saves.place(relx=0.5, rely=0.6, anchor=tk.CENTER) |
| 84 | + |
| 85 | + label_destination = tk.Label(root, text="Copy your actual saves before changing modpack!", bg='gray', fg='white') |
| 86 | + label_destination.place(relx=0.5, rely=0.8, anchor=tk.CENTER) |
| 87 | + |
| 88 | + button_destination = tk.Button(root, text="Import saves", command=copy_saves_to_destination, bg='gray', fg='white') |
| 89 | + button_destination.place(relx=0.5, rely=0.9, anchor=tk.CENTER) |
| 90 | + |
| 91 | + root.mainloop() |
| 92 | + |
| 93 | + |
| 94 | +if __name__ == "__main__": |
| 95 | + main() |
0 commit comments