diff --git a/README.md b/README.md index 226755d..32c853a 100644 --- a/README.md +++ b/README.md @@ -89,8 +89,9 @@ python3 Musicreater.py 3. 感谢由 Charlie_Ping “查理平” 带来的bdx转换功能 4. 感谢由 CMA_2401PT 带来的 BDXWorkShop 供本程序对于bdx操作的指导 5. 感谢由 Miracle Plume “神羽” \带来的羽音缭绕基岩版音色资源包 -6. 感谢广大群友为此程序提供的测试等支持 -7. 若您对我们有所贡献但您的名字没有显示在此列表中,请联系我! +6. 感谢 Arthur Morgan 对本程序的排错提出了最大的支持 +7. 感谢广大群友为此程序提供的测试等支持 +8. 若您对我们有所贡献但您的名字没有显示在此列表中,请联系我! ### 作者\<*金羿*\>(W-YI)联系方式 diff --git a/README_en.md b/README_en.md index 334034a..af1de93 100644 --- a/README_en.md +++ b/README_en.md @@ -83,14 +83,15 @@ Musicreater - > function (package) - > the following four new functions ### Thanks -1. Thank [Fuckcraft](https://github.com/fuckcraft) (“鸣凤鸽子” ,etc) for the function of Creating the Websocket Server for Minecraft: Bedrock Edition. +1. Thank [Fuckcraft](https://github.com/fuckcraft) *(“鸣凤鸽子” ,etc)* for the function of Creating the Websocket Server for Minecraft: Bedrock Edition. - *!! They have given me the rights to directly copy the lib into Musicreater* -2. Thank 昀梦\ for finding and correcting the bugs in the commands that *Musicreater* Created. -3. Thank Charlie_Ping “查理平” for bdx convert funtion. -4. Thank CMA_2401PT for BDXWorkShop as the .bdx structure's operation guide. -5. Thank Miracle Plume “神羽” \ for the Miracle Plume Bedrock Edition Audio Resource Pack -6. Thanks for a lot of groupmates who support me and help me to test the program. -7. If you have give me some help but u haven't been in the list, please contact me. +2. Thank *昀梦*\ for finding and correcting the bugs in the commands that *Musicreater* Created. +3. Thank *Charlie_Ping “查理平”* for bdx convert funtion. +4. Thank *CMA_2401PT* for BDXWorkShop as the .bdx structure's operation guide. +5. Thank *Miracle Plume “神羽”* \ for the Miracle Plume Bedrock Edition Audio Resource Pack +6. Thank *Arthur Morgan* for his/her biggest support for Musicreater +7. Thanks for a lot of groupmates who support me and help me to test the program. +8. If you have give me some help but u haven't been in the list, please contact me. ### Contact *Eilles(W-YI)*(金羿) diff --git a/bgArrayLib/__pycache__/bpm.cpython-38.pyc b/bgArrayLib/__pycache__/bpm.cpython-38.pyc index 817e667..672e09b 100644 Binary files a/bgArrayLib/__pycache__/bpm.cpython-38.pyc and b/bgArrayLib/__pycache__/bpm.cpython-38.pyc differ diff --git a/bgArrayLib/__pycache__/reader.cpython-38.pyc b/bgArrayLib/__pycache__/reader.cpython-38.pyc index d0a08a5..345313f 100644 Binary files a/bgArrayLib/__pycache__/reader.cpython-38.pyc and b/bgArrayLib/__pycache__/reader.cpython-38.pyc differ diff --git a/msctspt/bdxOpera_CP.py b/msctspt/bdxOpera_CP.py index ba32a30..831bf7f 100644 --- a/msctspt/bdxOpera_CP.py +++ b/msctspt/bdxOpera_CP.py @@ -4,10 +4,6 @@ import brotli '''感谢由 Charlie_Ping “查理平” 带来的bdx转换代码''' -# 诸葛亮与八卦阵帮忙修改语法 日期:---2022年1月19日 -# 统计:致命(三级)错误:0个;警告(二级)错误:0个;语法(一级)错误:7个 - - class BdxConverter: __header = "BD@" __bin_header = b"BDX" @@ -46,8 +42,8 @@ class BdxConverter: :return: list 给出的所有方块种类名称 """ block_type = set() - for block_ in self.blocks: - block_type.add(block_["block_name"]) + for block in self.blocks: + block_type.add(block["block_name"]) block_type = list(block_type) return block_type @@ -78,7 +74,6 @@ class BdxConverter: f.write(brotli.compress(_bytes)) f.close() return - def upload_blocks(self): """ 计算差值 @@ -88,17 +83,17 @@ class BdxConverter: :return: """ _types = b"" - for block_ in self.blocks: + for block in self.blocks: # print(f"当前方块:{block['block_name']}, 位置: {block['direction']}]") - diff = self.move_pointer(self.direction, block_["direction"]) + diff = self.move_pointer(self.direction, block["direction"]) _types += diff - if block_["block_name"] in ["command_block", - "chain_command_block", - "repeating_command_block"]: - _types += self.obtain_command_block(block_) + if block["block_name"] in ["command_block", + "chain_command_block", + "repeating_command_block"]: + _types += self.obtain_command_block(block) else: - _types += self.obtain_universal_block(block_) - self.direction = block_["direction"] + _types += self.obtain_universal_block(block) + self.direction = block["direction"] return _types def move_pointer(self, direction: list, new_direction): @@ -153,21 +148,21 @@ class BdxConverter: return pointer_type + num_byte return pointer_type - def obtain_universal_block(self, block1): + def obtain_universal_block(self, block): """ 给定一个方块, 返回此方块在这个bdx中的id和方块data - :param block1: {block_name: str,particular_value: int} + :param block: {block_name: str,particular_value: int} :return: bytes """ - block_id = b"\x07" + self.block_type.index(block1["block_name"]).to_bytes(2, byteorder="big", signed=False) - particular_value = block1["particular_value"].to_bytes(2, byteorder="big", signed=False) + block_id = b"\x07" + self.block_type.index(block["block_name"]).to_bytes(2, byteorder="big", signed=False) + particular_value = block["particular_value"].to_bytes(2, byteorder="big", signed=False) block_header = block_id + particular_value return block_header - def obtain_command_block(self, block1): + def obtain_command_block(self, block): """ 给定一个命令方块,返回命令方块各种数据 - :param block1: { + :param block: { "direction": [x: int, y: int, z: int] "block_name": str, "particular_value": int, @@ -184,24 +179,23 @@ class BdxConverter: :return: bytes of command_block """ - block_id = b"\x1b" + self.block_type.index(block1["block_name"]).to_bytes(2, byteorder="big", signed=False) - particular_value = block1["particular_value"].to_bytes(2, byteorder="big", signed=False) + block_id = b"\x1b" + self.block_type.index(block["block_name"]).to_bytes(2, byteorder="big", signed=False) + particular_value = block["particular_value"].to_bytes(2, byteorder="big", signed=False) block_header = block_id + particular_value for i in [ - block1["impluse"].to_bytes(4, byteorder="big", signed=False), - bytes(block1["command"], encoding="utf-8") + b"\x00", - bytes(block1["customName"], encoding="utf-8") + b"\x00", - bytes(block1["lastOutput"], encoding="utf-8") + b"\x00", - block1["tickdelay"].to_bytes(4, byteorder="big", signed=True), - block1["executeOnFirstTick"].to_bytes(1, byteorder="big"), - block1["trackOutput"].to_bytes(1, byteorder="big"), - block1["conditional"].to_bytes(1, byteorder="big"), - block1["needRedstone"].to_bytes(1, byteorder="big") + block["impluse"].to_bytes(4, byteorder="big", signed=False), + bytes(block["command"], encoding="utf-8") + b"\x00", + bytes(block["customName"], encoding="utf-8") + b"\x00", + bytes(block["lastOutput"], encoding="utf-8") + b"\x00", + block["tickdelay"].to_bytes(4, byteorder="big", signed=True), + block["executeOnFirstTick"].to_bytes(1, byteorder="big"), + block["trackOutput"].to_bytes(1, byteorder="big"), + block["conditional"].to_bytes(1, byteorder="big"), + block["needRedstone"].to_bytes(1, byteorder="big") ]: block_header += i return block_header - if __name__ == '__main__': block = [{"direction": [-1, -1, -1], "block_name": "concrete", "particular_value": 5}, {"direction": [1, 5, 1], "block_name": "stained_glass", "particular_value": 7}, @@ -218,4 +212,4 @@ if __name__ == '__main__': }, {"direction": [3, 4, 1], "block_name": "concrete", "particular_value": 6}, {"direction": [-123412133, 4, 1], "block_name": "concrete", "particular_value": 7}] - bdx = BdxConverter("./test02.bdx", "Charlie_Ping", block) + bdx = BdxConverter("./test02.bdx", "Charlie_Ping",block) diff --git a/msctspt/funcOpera.py b/msctspt/funcOpera.py index c99fe49..50d7d5b 100644 --- a/msctspt/funcOpera.py +++ b/msctspt/funcOpera.py @@ -92,7 +92,7 @@ def funSplit(bigFile, maxCmdLen: int = 10000): return parts -# 注意!播放器应该为个人独立播放器,此处bug需要修改 + def makeFuncFiles(musicset, path='./'): """在指定目录下生成函数文件""" from nmcsup.trans import Note2Cmd @@ -139,6 +139,20 @@ def makeFuncFiles(musicset, path='./'): log("完成============================") + + + + + + + + + + + + + + def makeFunDir(musicset, path='./'): """在指定目录下生成函数包文件夹""" import os @@ -178,37 +192,38 @@ def makeFunDir(musicset, path='./'): log("完成============================") -def makeNewFuncFiles(musicset, path='./'): + + + + + + + +def makeNewFuncFiles(musicset, path='./', isProsess:bool = False): """在指定目录下生成函数文件""" from msctspt.transfer import newList_conversion_SinglePlayer commands = [] starts = [] starts.__len__() starts.append("scoreboard objectives add " + musicset['musics'][0]['set']['ScoreboardName'] + " dummy\n") - starts.append("summon armor_stand " + musicset['musics'][0]['set']['EntityName'] + '\n') - starts.append("scoreboard objectives setdisplay sidebar " + musicset['musics'][0]['set']['ScoreboardName'] + '\n') - starts.append("scoreboard players set @e[type=armor_stand, name=\"" + musicset['musics'][0]['set']['EntityName'] + - "\"] " + musicset['musics'][0]['set']['ScoreboardName'] + " 0" + '\n') + # starts.append("summon armor_stand " + musicset['musics'][0]['set']['EntityName'] + '\n') + # starts.append("scoreboard objectives setdisplay sidebar " + musicset['musics'][0]['set']['ScoreboardName'] + '\n') + # starts.append("scoreboard players set @e[type=armor_stand, name=\"" + musicset['musics'][0]['set']['EntityName'] +"\"] " + musicset['musics'][0]['set']['ScoreboardName'] + " 0" + '\n') + log("=========================正在在此处生成文件:" + path) - commands.append("scoreboard players add @e[name=\"" + musicset['musics'][0]['set']['EntityName'] + "\"] " + - musicset['musics'][0]['set']['ScoreboardName'] + " 1\n") + + # commands.append("scoreboard players add @e[name=\"" + musicset['musics'][0]['set']['EntityName'] + "\"] " + musicset['musics'][0]['set']['ScoreboardName'] + " 1\n") maxlen = -1 for i in range(len(musicset['musics'])): log('写入第' + str(i) + '个数据') - # commands.append("execute @e[name=\"" + musicset['musics'][i]['set']['EntityName'] + "\",scores={" + - # musicset['musics'][i]['set']['ScoreboardName'] + "=1..10}] ~~~ title @a" + musicset['mainset'] - # [ - # 'PlayerSelect'] + " title " + musicset['mainset']['MusicTitle'] + "\n") - # commands.append("execute @e[name=\"" + musicset['musics'][i]['set']['EntityName'] + "\",scores={" + - # musicset['musics'][i]['set']['ScoreboardName'] + "=1..10}] ~~~ title @a" + musicset['mainset'] - # [ - # 'PlayerSelect'] + " subtitle 本函数乐曲由§b§l凌云§r§3函数音乐创建§r生成\n") + if len(musicset['musics'][i]['notes']) > maxlen: maxlen = len(musicset['musics'][i]['notes']) with open(path + musicset['mainset']['MusicTitle'] + '_Part' + str(i) + '.mcfunction', 'w', encoding='UTF-8') as f: f.writelines(newList_conversion_SinglePlayer(musicset['musics'][i]['notes'], - musicset['musics'][i]['set']['ScoreboardName'])) + musicset['musics'][i]['set']['ScoreboardName'], + musicset['musics'][i]['set']['Instrument'])) if musicset['mainset']['IsRepeat']: log("增加重复语句") for i in range(len(musicset['musics'])): @@ -229,6 +244,19 @@ def makeNewFuncFiles(musicset, path='./'): log("完成============================") + + + + + + + + + + + + + def makeNewFunDir(musicset, path='./'): """在指定目录下生成函数包文件夹""" import os diff --git a/msctspt/transfer.py b/msctspt/transfer.py index 37e179e..2ad789d 100644 --- a/msctspt/transfer.py +++ b/msctspt/transfer.py @@ -25,7 +25,7 @@ def hans2pinyin(hans, style=3): return final -def classList_conversion_SinglePlayer(List: list, ScoreboardName: str, Instrument: str, playerSelection: str = '', +def classList_conversion_SinglePlayer(List: list, ScoreboardName: str, playerSelection: str = '', isProsess: bool = False) -> list: from bgArrayLib.compute import round_up from bgArrayLib.pitchStrConstant import pitch @@ -44,7 +44,7 @@ def classList_conversion_SinglePlayer(List: list, ScoreboardName: str, Instrumen commands.append( f"execute @a{playerSelection} ~ ~ ~ execute @s[scores={{{ScoreboardName}=" f"{str(round_up(i.time_position)).replace('.0', '')}}}] ~ ~{127 - i.velocity} " - f"~ playsound {Instrument} @s ~ ~ ~ 1000 {pitch.get(str(i.pitch))} 1000\n") + f"~ playsound {i.instrument} @s ~ ~ ~ 1000 {pitch.get(str(i.pitch))} 1000\n") if isProsess: commands.append( f"execute @a{playerSelection} ~ ~ ~ execute @s[scores={{{ScoreboardName}=" diff --git a/nmcsup/__pycache__/const.cpython-38.pyc b/nmcsup/__pycache__/const.cpython-38.pyc index a9303cd..54f49db 100644 Binary files a/nmcsup/__pycache__/const.cpython-38.pyc and b/nmcsup/__pycache__/const.cpython-38.pyc differ diff --git a/nmcsup/__pycache__/nmcreader.cpython-38.pyc b/nmcsup/__pycache__/nmcreader.cpython-38.pyc index 7800484..3d6a0a7 100644 Binary files a/nmcsup/__pycache__/nmcreader.cpython-38.pyc and b/nmcsup/__pycache__/nmcreader.cpython-38.pyc differ diff --git a/测试用/铭刻时间的歌.mid b/测试用/铭刻时间的歌.mid new file mode 100644 index 0000000..ff8d124 Binary files /dev/null and b/测试用/铭刻时间的歌.mid differ