From 6f391567bad288a90cf825a9ccb2b0a6f910aae5 Mon Sep 17 00:00:00 2001 From: EillesWan Date: Mon, 19 Aug 2024 02:28:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86API=E5=B0=8F=E5=B9=85?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=8C=87=E4=BB=A4=E7=9A=84=E8=AE=A1=E5=88=86=E6=9D=BF?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E5=99=A8=E9=99=84=E5=8A=A0=E5=8C=85=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=92=AD=E6=94=BE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MANIFEST.in | 13 +++++++++++ Musicreater/__init__.py | 8 +++---- Musicreater/main.py | 4 ++-- Musicreater/plugin/addonpack/main.py | 32 +++++++++++++++++++++++----- Musicreater/plugin/archive.py | 9 ++++++-- Musicreater/subclass.py | 4 ++-- README.md | 1 + pyproject.toml | 2 ++ setup.py | 23 +++++++++++--------- 9 files changed, 71 insertions(+), 25 deletions(-) create mode 100644 MANIFEST.in create mode 100644 pyproject.toml diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..173e2a9 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,13 @@ +recursive-include *.md +include LICENSE.md +exclude fcwslib/* +exclude bgArrayLib/* +exclude Packer/* +exclude ./*.mid +exclude ./*.MSQ +exclude ./MSCT_Packer.py +exclude resources/poem.md +exclude resources/* +include requirements.txt +include README_EN.md +include README.md \ No newline at end of file diff --git a/Musicreater/__init__.py b/Musicreater/__init__.py index 285467e..7a7aaac 100644 --- a/Musicreater/__init__.py +++ b/Musicreater/__init__.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- """一个简单的我的世界音频转换库 音·创 (Musicreater) -是一款免费开源的针对《我的世界》的midi音乐转换库 +是一款免费开源的《我的世界》数字音频支持库。 Musicreater(音·创) -A free open source library used for convert midi file into formats that is suitable for **Minecraft**. +A free open source library used for dealing with **Minecraft** digital musics. 版权所有 © 2024 金羿 & 诸葛亮与八卦阵 Copyright © 2024 EillesWan & bgArray @@ -22,8 +22,8 @@ The Licensor of Musicreater("this project") is Eilles Wan, bgArray. # 若需转载或借鉴 许可声明请查看仓库目录下的 License.md -__version__ = "2.2.0" -__vername__ = "高精度时间支持" +__version__ = "2.2.1" +__vername__ = "部分API小幅度新增内容" __author__ = ( ("金羿", "Eilles Wan"), ("诸葛亮与八卦阵", "bgArray"), diff --git a/Musicreater/main.py b/Musicreater/main.py index ffccb57..a3352c8 100644 --- a/Musicreater/main.py +++ b/Musicreater/main.py @@ -3,9 +3,9 @@ """ 音·创 (Musicreater) -一款免费开源的针对《我的世界》音乐的支持库 +是一款免费开源的《我的世界》数字音频支持库。 Musicreater (音·创) -A free open source library used for **Minecraft** musics. +A free open source library used for dealing with **Minecraft** digital musics. 版权所有 © 2024 金羿 & 诸葛亮与八卦阵 Copyright © 2024 EillesWan & bgArray diff --git a/Musicreater/plugin/addonpack/main.py b/Musicreater/plugin/addonpack/main.py index bbda69e..6c4785a 100644 --- a/Musicreater/plugin/addonpack/main.py +++ b/Musicreater/plugin/addonpack/main.py @@ -74,6 +74,10 @@ def to_addon_pack_in_score( pack_description=f"{midi_cvt.music_name} 音乐播放包,MCFUNCTION(MCPACK) 计分播放器 - 由 音·创 生成", pack_name=midi_cvt.music_name + "播放", modules_description=f"无 - 由 音·创 生成", + format_version=1 if midi_cvt.enable_old_exe_format else 2, + pack_engine_version=( + None if midi_cvt.enable_old_exe_format else [1, 19, 50] + ), ), fp=f, indent=4, @@ -205,9 +209,14 @@ def to_addon_pack_in_delay( pack_description=f"{midi_cvt.music_name} 音乐播放包,MCSTRUCTURE(MCPACK) 延迟播放器 - 由 音·创 生成", pack_name=midi_cvt.music_name + "播放", modules_description=f"无 - 由 音·创 生成", + format_version=1 if midi_cvt.enable_old_exe_format else 2, + pack_engine_version=( + None if midi_cvt.enable_old_exe_format else [1, 19, 50] + ), ), fp=f, indent=4, + ensure_ascii=False, ) # 写入stop.mcfunction @@ -354,6 +363,8 @@ def to_addon_pack_in_repeater( dist_path: str, progressbar_style: Optional[ProgressBarStyle], player: str = "@a", + axis_side: Literal["z+", "z-", "Z+", "Z-", "x+", "x-", "X+", "X-"] = "z+", + basement_block: str = "concrete", max_height: int = 65, ) -> Tuple[int, int]: """ @@ -403,6 +414,10 @@ def to_addon_pack_in_repeater( pack_description=f"{midi_cvt.music_name} 音乐播放包,MCSTRUCTURE(MCPACK) 中继器播放器 - 由 音·创 生成", pack_name=midi_cvt.music_name + "播放", modules_description=f"无 - 由 音·创 生成", + format_version=1 if midi_cvt.enable_old_exe_format else 2, + pack_engine_version=( + None if midi_cvt.enable_old_exe_format else [1, 19, 50] + ), ), fp=f, indent=4, @@ -422,9 +437,11 @@ def to_addon_pack_in_repeater( ) struct, size, end_pos = commands_to_redstone_delay_structure( - command_list, - max_delay, - max_together, + commands=command_list, + delay_length=max_delay, + max_multicmd_length=max_together, + base_block=basement_block, + axis_=axis_side, compability_version_=compability_ver, ) with open( @@ -554,6 +571,7 @@ def to_addon_pack_in_repeater_divided_by_instrument( player: str = "@a", max_height: int = 65, base_block: str = "concrete", + axis_side: Literal["z+", "z-", "Z+", "Z-", "x+", "x-", "X+", "X-"] = "z+", ) -> Tuple[int, int]: """ 将midi以中继器播放器形式转换为mcstructure结构文件后打包成附加包,并在附加包中生成相应地导入函数 @@ -593,9 +611,13 @@ def to_addon_pack_in_repeater_divided_by_instrument( with open(f"{dist_path}/temp/manifest.json", "w", encoding="utf-8") as f: json.dump( behavior_mcpack_manifest( - pack_description=f"{midi_cvt.music_name} 音乐播放包,MCSTRUCTURE(MCPACK) 中继器播放器 - 由 音·创 生成", + pack_description=f"{midi_cvt.music_name} 音乐播放包,MCSTRUCTURE(MCPACK) 中继器播放器(拆分) - 由 音·创 生成", pack_name=midi_cvt.music_name + "播放", modules_description=f"无 - 由 音·创 生成", + format_version=1 if midi_cvt.enable_old_exe_format else 2, + pack_engine_version=( + None if midi_cvt.enable_old_exe_format else [1, 19, 50] + ), ), fp=f, indent=4, @@ -628,7 +650,7 @@ def to_addon_pack_in_repeater_divided_by_instrument( max_delay, max_multiple_cmd_count[inst], base_block, - "z+", + axis_=axis_side, compability_version_=compability_ver, ) diff --git a/Musicreater/plugin/archive.py b/Musicreater/plugin/archive.py index 9c83701..2e4d503 100644 --- a/Musicreater/plugin/archive.py +++ b/Musicreater/plugin/archive.py @@ -46,10 +46,12 @@ def compress_zipfile(sourceDir, outFilename, compression=8, exceptFile=None): def behavior_mcpack_manifest( + format_version: Union[Literal[1], Literal[2]] = 1, pack_description: str = "", pack_version: Union[List[int], Literal[None]] = None, pack_name: str = "", pack_uuid: Union[str, Literal[None]] = None, + pack_engine_version: Union[List[int], None] = None, modules_description: str = "", modules_version: List[int] = [0, 0, 1], modules_uuid: Union[str, Literal[None]] = None, @@ -64,8 +66,8 @@ def behavior_mcpack_manifest( now_date.month * 100 + now_date.day, now_date.hour * 100 + now_date.minute, ] - return { - "format_version": 1, + result = { + "format_version": format_version, "header": { "description": pack_description, "version": pack_version, @@ -81,3 +83,6 @@ def behavior_mcpack_manifest( } ], } + if pack_engine_version: + result["header"]["min_engine_version"] = pack_engine_version + return result diff --git a/Musicreater/subclass.py b/Musicreater/subclass.py index ebdacd0..2ed9722 100644 --- a/Musicreater/subclass.py +++ b/Musicreater/subclass.py @@ -414,8 +414,8 @@ class MineCommand: """ 转为我的世界函数文件格式(包含注释) """ - return "#[{cdt}]<{delay}> {ant}\n{cmd}".format( - cdt="CDT" if self.conditional else "", + return "# {cdt}<{delay}> {ant}\n{cmd}".format( + cdt="[CDT]" if self.conditional else "", delay=self.delay, ant=self.annotation_text, cmd=self.command_text, diff --git a/README.md b/README.md index c42d1bd..5cebeb9 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ - 感谢 **雷霆**\ 用他那令所有开发者都大为光火的操作方法为我们的程序找出错误,并提醒修复 bug。 - 感谢 **小埋**\ 反馈附加包生成时缺少描述和标题的问题。 -
感谢 **油炸**\ 激励我们不断开发新的内容。
+- 感谢 **雨**\ 反馈在新版本的指令格式下,计分板播放器的附加包无法播放的问题。 > 感谢广大群友为此库提供的测试和建议等 > diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..982c8bf --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[build-system] +requires = ["setuptools", "wheel", "mido"] \ No newline at end of file diff --git a/setup.py b/setup.py index 1ce742f..f522de5 100644 --- a/setup.py +++ b/setup.py @@ -1,22 +1,25 @@ # -*- coding: utf-8 -*- import setuptools -import Musicreater +import os +from Musicreater import __version__ -with open("requirements.txt", "r", encoding="utf-8") as fh: +os.chdir(os.path.dirname(os.path.abspath(__file__))) + +with open("./requirements.txt", "r", encoding="utf-8") as fh: dependences = fh.read().strip().split("\n") -with open("README_EN.md", "r", encoding="utf-8") as fh: +with open("./README_EN.md", "r", encoding="utf-8") as fh: long_description = fh.read().replace( "./docs/", "https://github.com/TriM-Organization/Musicreater/blob/master/docs/" ) setuptools.setup( name="Musicreater", - version=Musicreater.__version__, + version=__version__, author="金羿Eilles, bgArray, 鱼旧梦ElapsingDreams", author_email="TriM-Organization@hotmail.com", - description="一款免费开源的针对《我的世界》音乐的支持库\n" - "A free open-source python library used to convert midi into Minecraft.", + description="一款开源《我的世界》数字音频支持库。\n" + "A free open source library used for dealing with **Minecraft** digital musics.", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/TriM-Organization/Musicreater", @@ -24,15 +27,15 @@ setuptools.setup( classifiers=[ "Intended Audience :: Developers", "Natural Language :: Chinese (Simplified)", - "License :: OSI Approved :: Apache Software License", + # "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Topic :: Software Development :: Libraries", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", + "Topic :: Multimedia", + "Topic :: Multimedia :: Sound/Audio :: MIDI", ], # 需要安装的依赖 install_requires=dependences, + python_requires=">=3.8", )