Click for upload structure file



version: 1.20.? ~ 1.21(preview)
coordinate offset x*y*z
x:
y:
z:
nameTag:
0% import os import zipfile import js import time from js import document loading_try_count = 1 while document.getElementById("resourceLoading").style.display != "none": print("#"+i+" waiting for resource loading...") time.sleep(0.31) current_dir = os.getcwd() with zipfile.ZipFile(os.path.join(current_dir,'./libZip/python_modules.zip'), 'r') as zip_ref: zip_ref.extractall('./') with zipfile.ZipFile(os.path.join(current_dir,'./libZip/Vanilla_Resource_Pack.zip'), 'r') as zip_ref: zip_ref.extractall('./') with zipfile.ZipFile(os.path.join(current_dir,'./libZip/test_structures.zip'), 'r') as zip_ref: zip_ref.extractall('./') with zipfile.ZipFile(os.path.join(current_dir,'./libZip/lookups.zip'), 'r') as zip_ref: zip_ref.extractall('./') import sys sys.path.append('./python_modules') ################################## from io import BytesIO # from js import document from pyodide.ffi.wrappers import add_event_listener from upTest import add,conver files = [] async def run(e): print("##################################") file_buffer = files[0] offset = [0,0,0] try: offset = [int(document.getElementById("x_input").value),int(document.getElementById("y_input").value),int(document.getElementById("z_input").value)] except: print(">* error--> offset,set offset to [0,0,0]") pass nameTag = "love" try: nameTag = document.getElementById("nameTag").value if nameTag == "": print(">* error--> nameTag,set nameTag to 'love'") nameTag = "love" except: print(">* error--> nameTag,set nameTag to 'love'") pass print(">> now!!!") print(">> offset-->",offset) print(">> nameTag-->",nameTag) add(nameTag,file_buffer,offset) conver() async def get_bytes_from_file(file): array_buf = await file.arrayBuffer() return array_buf.to_bytes() async def upload_file_and_show(e): print("##################################") print(">> 导入成功,请点击开始制作") file_list = e.target.files first_item = file_list.item(0) my_bytes: bytes = await get_bytes_from_file(first_item) file_buffer = BytesIO(my_bytes) del first_item del my_bytes files.append(file_buffer) document.getElementById("run").style.display = "block" fileInput = document.getElementById('fileInput') runButton = document.getElementById('run') add_event_listener(fileInput, "change", upload_file_and_show) add_event_listener(runButton, "click", run) document.getElementById("pyLoading").style.display = "none" document.getElementById("linkList").style.display = "none" # print("time.time()*1000",int(time.time()*1000) ) # print("document", int(document.getElementById("startTime").innerHTML)) print("loading",int(time.time()*1000) - int(document.getElementById("startTime").innerHTML),"ms")