diff --git a/Musicreater.py b/Musicreater.py index 427d828..ca3bf99 100644 --- a/Musicreater.py +++ b/Musicreater.py @@ -890,6 +890,59 @@ def __main__(): + def world2RyStruct(): + outdir = tkinter.filedialog.askdirectory(title='请选择世界文件夹生成的位置', initialdir=r'./'); + if outdir == None or outdir == '': + return; + else: + outdir+='/'; + while True: + try: + begp = tkinter.simpledialog.askstring(title = '坐标信息输入',prompt='请输入区域选择的开始坐标:',initialvalue = '16 4 16') + if begp == None or begp == '': + return; + begp = [int(begp.split(' ')[0]), int(begp.split(' ')[1]), int(begp.split(' ')[2])] + except: + tkinter.messagebox.showerror(title="错误❌", message="您输入的格式有误,请重新输入!"); + continue + break + while True: + try: + endp = tkinter.simpledialog.askstring(title = '坐标信息输入',prompt='请输入区域选择的结束坐标:',initialvalue = '16 4 16') + if endp == None or endp == '': + return; + endp = [int(endp.split(' ')[0]), int(endp.split(' ')[1]), int(endp.split(' ')[2])] + except: + tkinter.messagebox.showerror(title="错误❌", message="您输入的格式有误,请重新输入!"); + continue + break + isAir = tkinter.messagebox.askyesno("请确认","所选区块导出时是否需要保留空气方块?") + fileName = tkinter.filedialog.asksaveasfilename(title='生成.RyStruct文件', initialdir=r'./', filetypes=[('音·创结构文件', '.RyStruct'), ('全部类型', '*')], defaultextension='*.RyStruct',initialfile='*.RyStruct') + if fileName == None or fileName == '': + log("取消") + return; + from msctspt.transfer import ryStruct + rys = ryStruct() + rys.World2Rys(outdir,begp,endp,isAir) + try: + with open(fileName,'w',encoding='utf-8') as f: + json.dump(rys,f) + tkinter.messagebox.showinfo("成功✔",'文件已生成\n'+fileName) + except: + tkinter.messagebox.showerror("失败❌",'文件无法生成\n'+fileName) + + + def world2BDX(): + tkinter.messagebox.showerror("错误",'本功能尚未开发。') + + + + + + + + + @@ -1115,7 +1168,7 @@ def __main__(): - #创建生成函数菜单 + #创建函数菜单 funcmenu = tk.Menu(main_menu_bar, tearoff=0) funcmenu.add_command(label=u"生成文件至...", command=MakeCMD) funcmenu.add_command(label=u"生成函数包至...", command=MakeCMDdir) @@ -1126,28 +1179,33 @@ def __main__(): - #创建生成至世界菜单 + #创建世界菜单 worldmenu = tk.Menu(main_menu_bar, tearoff=0); worldmenu.add_command(label=u"将音乐以方块存储生成地图", command=ToBlockWorldEpt); worldmenu.add_command(label=u"将音乐以方块存储载入地图…", command=ToBlockWorld); - worldmenu.add_command(label=u"生成符合当前音乐的函数播放器…", command=MakeFuncPlayer); - worldmenu.add_separator(); + worldmenu.add_separator() worldmenu.add_command(label=u"将音乐以指令存储生成地图", command=ToCmdWorldEpt); worldmenu.add_command(label=u"将音乐以指令存储载入地图…", command=ToCmdWorld); - worldmenu.add_command(label=u"将选中音轨以指令存储生成.bdx文件", command=toScbBDXfile) - worldmenu.add_separator(); + worldmenu.add_separator() worldmenu.add_command(label=u"将音乐以音符盒存储生成地图", command=toRSworldEPT); worldmenu.add_command(label=u"将音乐以音符盒存储载入地图…", command=toRSworld); - worldmenu.add_separator(); - worldmenu.add_command(label=u"将函数载入世界…", command=func2World); - worldmenu.add_command(label=u"将大函数分割并建立执行链…", command=bigFunc2World); # 将子菜单加入到菜单条中 main_menu_bar.add_cascade(label=u"世界", menu=worldmenu); + # 创建其他功能菜单 + otherMenu = tk.Menu(main_menu_bar, tearoff=0) + otherMenu.add_command(label=u"生成符合当前音乐的函数播放器…", command=MakeFuncPlayer) + worldmenu.add_separator(); + otherMenu.add_command(label=u"将选中音轨以指令存储生成.bdx文件…", command=toScbBDXfile) + otherMenu.add_command(label=u"由地图导出至.bdx文件…", command=world2BDX) + otherMenu.add_command(label=u"由地图导出至.RyStruct文件…", command=world2RyStruct) + worldmenu.add_separator(); + worldmenu.add_command(label=u"将函数载入世界…", command=func2World); + worldmenu.add_command(label=u"将大函数分割并建立执行链…", command=bigFunc2World); - # 创建生成菜单 + # 创建实验功能菜单 trymenu = tk.Menu(main_menu_bar, tearoff=0) trymenu.add_command(label=u"展示生成结果", command=ShowCMD) trymenu.add_command(label=u"建立位于localhost:8080上的websocket服务器播放选中音轨", command=wsPlay) diff --git a/README.md b/README.md index 3e0769f..6065c85 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,10 @@ #### Windows7+ -0. [下载]本程序 +0. [下载](https://gitee.com/EillesWan/Musicreater/repository/archive/master.zip)本程序 1. 安装Python 3.8.10 - [下载64位安装包] - [下载32位安装包] + [下载64位安装包](https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe) + [下载32位安装包](https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe) 2. 以管理员身份运行 补全库.py - 按下 Ctrl+Shift+Esc 打开任务管理器 - 点击 "文件" 菜单中的 运行新任务 命令 @@ -53,17 +53,10 @@ python3 Musicreater.py ### 致谢 -1. 感谢由 [Fuckcraft] “鸣凤鸽子”等 带来的我的世界websocket服务器功能 +1. 感谢由 [Fuckcraft](https://gitee.com/fuckcraft) “鸣凤鸽子”等 带来的我的世界websocket服务器功能 2. 感谢 昀梦 找出指令生成错误bug并指正 3. 感谢由 Charlie_Ping “查理平” 带来的bdx转换功能 4. 感谢广大群友为此程序提供的测试等支持 +5. 若您为我找出了错误但您的名字没有显示在此列表中,请联系我! -#### 特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/msctspt/MSCT Dev Log.txt b/msctspt/MSCT Dev Log.txt index 533dde3..9cd169a 100644 --- a/msctspt/MSCT Dev Log.txt +++ b/msctspt/MSCT Dev Log.txt @@ -30,6 +30,14 @@ Copyright © W-YI 2021 新更新日志 + + + Beta 0.0.4 +2021 11 20 ~ 2021 11 21 +1.完全支持Linux系统 +2.支持以.RyStruct导出结构 +3.修复大量bug + Beta 0.0.3.1~0.0.3.5 2021 11 1~2021 11 2 diff --git a/msctspt/__pycache__/bugReporter.cpython-38.pyc b/msctspt/__pycache__/bugReporter.cpython-38.pyc index d364a83..23638fe 100644 Binary files a/msctspt/__pycache__/bugReporter.cpython-38.pyc and b/msctspt/__pycache__/bugReporter.cpython-38.pyc differ diff --git a/msctspt/bugReporter.py b/msctspt/bugReporter.py index 8cfe2fc..264539e 100644 --- a/msctspt/bugReporter.py +++ b/msctspt/bugReporter.py @@ -101,7 +101,7 @@ class version: libraries = ('mido','amulet','amulet-core','amulet-nbt','piano_transcription_inference','pypinyin','briefcase','toga','pyinstaller','kivy','py7zr') '''当前所需库,有一些是开发用的,用户不需要安装''' - version = ('0.0.3.5','Beta',) + version = ('0.0.4','Beta',) '''当前版本''' def __init__(self) -> None: diff --git a/msctspt/transfer.py b/msctspt/transfer.py index 47b782f..173483d 100644 --- a/msctspt/transfer.py +++ b/msctspt/transfer.py @@ -224,4 +224,58 @@ def note2RSworld(world:str,startpos:list,notes:list,instrument:str,speed:float = log("无法放置方块了,可能是因为区块未加载叭") level.save() level.close() - \ No newline at end of file + + + + + + + + + +class ryStruct: + + def __init__(self) -> None: + self.RyStruct = dict() + + def World2Rys(self,world:str,startp:list,endp:list,includeAir:bool=False): + + import amulet + import amulet_nbt + from amulet.api.block import Block + from amulet.utils.world_utils import block_coords_to_chunk_coords + + level = amulet.load_level(world) + + + for x in range(startp[0],endp[0]): + for y in range(startp[1],endp[1]): + for z in range(startp[2],endp[2]): + + RyStructBlock = dict() + + cx, cz = block_coords_to_chunk_coords(x, z) + chunk = level.get_chunk(cx, cz, "minecraft:overworld") + universal_block = chunk.block_palette[chunk.blocks[x - 16 * cx, y, z - 16 * cz]] + if universal_block == Block("universal_minecraft","air") and includeAir: + continue + universal_block_entity = chunk.block_entities.get((x, y, z), None) + + RyStructBlock["block"] = str(universal_block) + RyStructBlock["blockEntity"] = str(universal_block_entity) + + self.RyStruct[(x,y,z)] = RyStructBlock + + + return self.RyStruct + + + +''' +RyStruct = { + (0,0,0) = { + "block": str 完整的方块结构 + "blockEntity": str | 'None' + } +} +''' diff --git a/nmcsup/__pycache__/vers.cpython-38.pyc b/nmcsup/__pycache__/vers.cpython-38.pyc index 16feb35..d21a940 100644 Binary files a/nmcsup/__pycache__/vers.cpython-38.pyc and b/nmcsup/__pycache__/vers.cpython-38.pyc differ diff --git a/nmcsup/trans.py b/nmcsup/trans.py index 6200962..455a2b4 100644 --- a/nmcsup/trans.py +++ b/nmcsup/trans.py @@ -252,41 +252,3 @@ def Datas2BlkWorld(NoteData,world:str,dire:list): Blocks2World(world,[dire[0],dire[1],dire[2]+i],NoteData[i]) - - - - -def World2Rys(world:str,startp:list,endp:list,isAir:bool=False ): - level = amulet.load_level(world) - RyStruct = {} - - for x in range(startp[0],endp[0]): - for y in range(startp[1],endp[1]): - for z in range(startp[2],endp[2]): - RyStructBlock = {} - cx, cz = block_coords_to_chunk_coords(x, z) - chunk = level.get_chunk(cx, cz, "minecraft:overworld") - universal_block = chunk.block_palette[chunk.blocks[x - 16 * cx, y, z - 16 * cz]] - if universal_block == Block("universal_minecraft","air") and isAir: - continue - universal_block_entity = chunk.block_entities.get((x, y, z), None) - universal_block.namespace - universal_block_entity.namespace - -#not be finished - -''' -RyStruct = { - (0,0,0) = { - "block":{ - "namespace":"", - "base_name":"", - "properties":{} - }, - "block_entity":{ - "namespace":"", - "base_name":"", - } - } -} -'''