mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2024-11-11 01:27:35 +08:00
日志和bug修改
This commit is contained in:
parent
7e13b22d46
commit
81eb8e5376
@ -658,6 +658,7 @@ def __main__():
|
|||||||
except ValueError: # 测试完为ValueError,故修改语法
|
except ValueError: # 测试完为ValueError,故修改语法
|
||||||
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
|
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
|
||||||
continue
|
continue
|
||||||
|
break
|
||||||
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[29], initialdir=r'./')
|
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[29], initialdir=r'./')
|
||||||
if Outdire is None or Outdire == '':
|
if Outdire is None or Outdire == '':
|
||||||
return
|
return
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
"""音创系列的音符对照表 以及一系列常数"""
|
"""音创系列的音符对照表 以及一系列常数"""
|
||||||
|
# 诸葛亮与八卦阵帮忙修改语法 日期:---2022年1月19日
|
||||||
|
# 统计:致命(三级)错误:0个;警告(二级)错误:0个;语法(一级)错误:109个
|
||||||
|
|
||||||
|
|
||||||
notes = {
|
notes = {
|
||||||
@ -96,9 +97,6 @@ notes = {
|
|||||||
'''音符对照表\n
|
'''音符对照表\n
|
||||||
音符:[MC音调, 声音频率, 方块名称, 数据值]'''
|
音符:[MC音调, 声音频率, 方块名称, 数据值]'''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 方块
|
# 方块
|
||||||
'''
|
'''
|
||||||
blocks = {
|
blocks = {
|
||||||
@ -195,7 +193,6 @@ blocks = {
|
|||||||
#向查理平致敬!!!!!
|
#向查理平致敬!!!!!
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
Blocks = {
|
Blocks = {
|
||||||
0.074: 'barrel',
|
0.074: 'barrel',
|
||||||
0.0787: 'beacon',
|
0.0787: 'beacon',
|
||||||
@ -290,8 +287,6 @@ Blocks = {
|
|||||||
'''频率对照表\n
|
'''频率对照表\n
|
||||||
MC音调:方块名称'''
|
MC音调:方块名称'''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 乐器
|
# 乐器
|
||||||
Instuments = {
|
Instuments = {
|
||||||
'note.banjo': '班卓',
|
'note.banjo': '班卓',
|
||||||
@ -315,6 +310,3 @@ Instuments = {
|
|||||||
'''乐器对照表\n
|
'''乐器对照表\n
|
||||||
乐器英文:中文
|
乐器英文:中文
|
||||||
翻译:雪莹工坊Fun-Fer'''
|
翻译:雪莹工坊Fun-Fer'''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,17 +1,53 @@
|
|||||||
"""提供对于音创系列的日志"""
|
"""提供对于音创系列的日志"""
|
||||||
|
# 诸葛亮与八卦阵帮忙修改语法 日期:---2022年1月19日
|
||||||
|
# 统计:致命(三级)错误:0个;警告(二级)错误:0个;语法(一级)错误:9个
|
||||||
|
|
||||||
import datetime,os
|
import logging
|
||||||
|
import os
|
||||||
|
import datetime
|
||||||
|
import sys
|
||||||
|
|
||||||
|
StrStartTime = str(datetime.datetime.now()).replace(':', '_')[:-7]
|
||||||
|
time = StrStartTime
|
||||||
|
|
||||||
|
main_path = './log/'
|
||||||
|
|
||||||
|
position = main_path + time
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
logger.setLevel(level=logging.INFO)
|
||||||
|
handler = logging.FileHandler(position + ".logger")
|
||||||
|
print(position + ".logger")
|
||||||
|
|
||||||
|
handler.setLevel(logging.INFO)
|
||||||
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
|
handler.setFormatter(formatter)
|
||||||
|
|
||||||
|
console = logging.StreamHandler()
|
||||||
|
console.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
logger.addHandler(handler)
|
||||||
|
logger.addHandler(console)
|
||||||
|
|
||||||
|
print("using Timbre_resources_package_generator_lib \n --made by 诸葛亮与八卦阵")
|
||||||
|
print(sys.path[0].replace("nmcsup\\logger", "log\\"))
|
||||||
|
|
||||||
|
# import logger
|
||||||
|
|
||||||
# 载入日志功能
|
# 载入日志功能
|
||||||
StrStartTime = str(datetime.datetime.now()).replace(':', '_')[:-7]
|
StrStartTime = str(datetime.datetime.now()).replace(':', '_')[:-7]
|
||||||
'''字符串型的程序开始时间'''
|
# logger.setting(StrStartTime)
|
||||||
|
"""字符串型的程序开始时间"""
|
||||||
|
|
||||||
|
|
||||||
def log(info:str = '',isPrinted:bool = True):
|
def log(info: str = '', isPrinted: bool = False, isLoggerLibRecord: bool = True):
|
||||||
'''将信息连同当前时间载入日志'''
|
# isLoggerLibRecord: 是否同时在logger库中记录
|
||||||
|
"""将信息连同当前时间载入日志"""
|
||||||
if not os.path.exists('./log/'):
|
if not os.path.exists('./log/'):
|
||||||
os.makedirs('./log/')
|
os.makedirs('./log/')
|
||||||
with open('./log/' + StrStartTime + '.msct.log', 'a', encoding='UTF-8') as f:
|
with open('./log/' + StrStartTime + '.msct.log', 'a', encoding='UTF-8') as f:
|
||||||
f.write(str(datetime.datetime.now())[11:19] + ' ' + info + '\n')
|
f.write(str(datetime.datetime.now())[11:19] + ' ' + info + '\n')
|
||||||
if isPrinted:
|
if isPrinted:
|
||||||
print(str(datetime.datetime.now())[11:19] + ' ' + info)
|
print(str(datetime.datetime.now())[11:19] + ' ' + info)
|
||||||
|
if isLoggerLibRecord:
|
||||||
|
logger.info(info)
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
|
|
||||||
"""音创系列的文件读取功能"""
|
"""音创系列的文件读取功能"""
|
||||||
|
|
||||||
|
# 诸葛亮与八卦阵帮忙修改语法 日期:---2022年1月19日
|
||||||
|
# 统计:致命(三级)错误:0个;警告(二级)错误:3个;语法(一级)错误:22个
|
||||||
|
|
||||||
|
|
||||||
from nmcsup.log import log
|
from nmcsup.log import log
|
||||||
from nmcsup.const import notes
|
from nmcsup.const import notes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 从格式文本文件读入一个音轨并存入一个列表
|
# 从格式文本文件读入一个音轨并存入一个列表
|
||||||
def ReadFile(fn : str) -> list:
|
def ReadFile(fn: str): # -> list
|
||||||
from nmcsup.trans import note2list
|
from nmcsup.trans import note2list
|
||||||
log('打开' + fn + "并读取音符")
|
log('打开' + fn + "并读取音符")
|
||||||
try:
|
try:
|
||||||
nat = open(fn, 'r', encoding='UTF-8').read().split(" ")
|
nat = open(fn, 'r', encoding='UTF-8').read().split(" ")
|
||||||
del fn
|
del fn
|
||||||
except:
|
except FileNotFoundError:
|
||||||
log("找不到读取目标文件")
|
log("找不到读取目标文件")
|
||||||
return False
|
return False
|
||||||
Notes = []
|
Notes = []
|
||||||
@ -29,20 +28,21 @@ def ReadFile(fn : str) -> list:
|
|||||||
|
|
||||||
|
|
||||||
# 从midi读入多个音轨,返回多个音轨列表
|
# 从midi读入多个音轨,返回多个音轨列表
|
||||||
def ReadMidi(midfile : str ) -> list:
|
def ReadMidi(midfile: str): # -> list
|
||||||
import mido
|
import mido
|
||||||
from msctspt.threadOpera import NewThread
|
from msctspt.threadOpera import NewThread
|
||||||
Notes = []
|
Notes = []
|
||||||
try:
|
try:
|
||||||
mid = mido.MidiFile(midfile)
|
mid = mido.MidiFile(midfile)
|
||||||
except:
|
except FileNotFoundError:
|
||||||
log("找不到文件或无法读取文件" + midfile)
|
log("找不到文件或无法读取文件" + midfile)
|
||||||
return False
|
return False
|
||||||
# 解析
|
# 解析
|
||||||
ks = list(notes.values())
|
ks = list(notes.values())
|
||||||
def loadMidi(track):
|
|
||||||
|
def loadMidi(track1):
|
||||||
datas = []
|
datas = []
|
||||||
for i in track:
|
for i in track1:
|
||||||
if i.is_meta:
|
if i.is_meta:
|
||||||
log('元信息' + str(i))
|
log('元信息' + str(i))
|
||||||
pass # 不处理元信息
|
pass # 不处理元信息
|
||||||
@ -58,6 +58,7 @@ def ReadMidi(midfile : str ) -> list:
|
|||||||
del msg
|
del msg
|
||||||
log('音符增加' + str(datas))
|
log('音符增加' + str(datas))
|
||||||
return datas
|
return datas
|
||||||
|
|
||||||
for j, track in enumerate(mid.tracks):
|
for j, track in enumerate(mid.tracks):
|
||||||
th = NewThread(loadMidi, (track,))
|
th = NewThread(loadMidi, (track,))
|
||||||
th.start()
|
th.start()
|
||||||
@ -66,16 +67,14 @@ def ReadMidi(midfile : str ) -> list:
|
|||||||
return Notes
|
return Notes
|
||||||
|
|
||||||
|
|
||||||
|
def ReadOldProject(fn: str): # -> list
|
||||||
|
|
||||||
def ReadOldProject(fn:str) -> list:
|
|
||||||
import json
|
import json
|
||||||
from nmcsup.trans import note2list
|
from nmcsup.trans import note2list
|
||||||
log("读取文件:" + fn)
|
log("读取文件:" + fn)
|
||||||
try:
|
try:
|
||||||
with open(fn, 'r', encoding='UTF-8') as c:
|
with open(fn, 'r', encoding='UTF-8') as c:
|
||||||
dataset = json.load(c)
|
dataset = json.load(c)
|
||||||
except:
|
except FileNotFoundError:
|
||||||
print('找不到文件:' + fn + ",请查看您是否输入正确")
|
print('找不到文件:' + fn + ",请查看您是否输入正确")
|
||||||
log("丢失" + fn)
|
log("丢失" + fn)
|
||||||
return False
|
return False
|
||||||
@ -83,5 +82,3 @@ def ReadOldProject(fn:str) -> list:
|
|||||||
dataset['musics'][i]['notes'] = note2list(dataset['musics'][i]['notes'])
|
dataset['musics'][i]['notes'] = note2list(dataset['musics'][i]['notes'])
|
||||||
# 返回 音轨列表 选择器
|
# 返回 音轨列表 选择器
|
||||||
return dataset
|
return dataset
|
||||||
|
|
||||||
|
|
||||||
|
127
nmcsup/trans.py
127
nmcsup/trans.py
@ -1,19 +1,23 @@
|
|||||||
|
|
||||||
"""音创系列的转换功能"""
|
"""音创系列的转换功能"""
|
||||||
|
# 诸葛亮与八卦阵帮忙修改语法 日期:---2022年1月19日
|
||||||
|
# 统计:致命(三级)错误:0个;警告(二级)错误:2个;语法(一级)错误:192个
|
||||||
|
|
||||||
|
|
||||||
from nmcsup.log import log
|
from nmcsup.log import log
|
||||||
|
|
||||||
|
|
||||||
|
import amulet
|
||||||
|
import amulet_nbt
|
||||||
|
from amulet.api.block import Block
|
||||||
|
from amulet.api.block_entity import BlockEntity
|
||||||
|
from amulet.utils.world_utils import block_coords_to_chunk_coords
|
||||||
|
from amulet_nbt import TAG_String, TAG_Compound, TAG_Byte
|
||||||
|
|
||||||
|
|
||||||
# 输入一个列表 [ [str, float ], [], ... ] 音符str 值为持续时间float
|
# 输入一个列表 [ [str, float ], [], ... ] 音符str 值为持续时间float
|
||||||
def note2list(Notes: list) -> list:
|
def note2list(Notes: list) -> list:
|
||||||
from nmcsup.const import notes
|
from nmcsup.const import notes
|
||||||
|
|
||||||
def change(base):
|
def change(base):
|
||||||
enwo = {
|
enwo = {
|
||||||
'a': 'A',
|
'a': 'A',
|
||||||
@ -40,6 +44,7 @@ def note2list(Notes : list) -> list:
|
|||||||
if k in base:
|
if k in base:
|
||||||
base = base.replace(k, v)
|
base = base.replace(k, v)
|
||||||
return base
|
return base
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
log(" === 音符列表=>音调列表")
|
log(" === 音符列表=>音调列表")
|
||||||
for i in Notes:
|
for i in Notes:
|
||||||
@ -55,8 +60,6 @@ def note2list(Notes : list) -> list:
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def mcnote2freq(Notes):
|
def mcnote2freq(Notes):
|
||||||
from nmcsup.const import notes
|
from nmcsup.const import notes
|
||||||
mcnback = {}
|
mcnback = {}
|
||||||
@ -71,78 +74,70 @@ def mcnote2freq(Notes):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# MP3文件转midi文件
|
# MP3文件转midi文件
|
||||||
def Mp32Mid(mp3File, midFile):
|
def Mp32Mid(mp3File, midFile):
|
||||||
from piano_transcription_inference import PianoTranscription, sample_rate, load_audio
|
from piano_transcription_inference import PianoTranscription, sample_rate, load_audio
|
||||||
# 加载
|
# 加载
|
||||||
(audio, _) = load_audio(mp3File, sr=sample_rate, mono=True)
|
(audio, _) = load_audio(mp3File, sr=sample_rate) # , mono=True
|
||||||
# 实例化并转换
|
# 实例化并转换
|
||||||
PianoTranscription(device="cpu").transcribe(audio, midFile)
|
PianoTranscription(device="cpu").transcribe(audio, midFile)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 传入一个音符列表转为指令列表
|
# 传入一个音符列表转为指令列表
|
||||||
def Note2Cmd(Notes : list,ScoreboardName:str,Instrument:str, PlayerSelect:str='',isProsess:bool=False) -> list:
|
def Note2Cmd(Notes: list, ScoreboardName: str, Instrument: str, PlayerSelect: str = '',
|
||||||
|
isProsess: bool = False) -> list:
|
||||||
commands = []
|
commands = []
|
||||||
a = 0.0
|
a = 0.0
|
||||||
if isProsess:
|
if isProsess:
|
||||||
length = len(Notes)
|
length = len(Notes)
|
||||||
j = 1
|
j = 1
|
||||||
for i in range(len(Notes)):
|
for i in range(len(Notes)):
|
||||||
commands.append("execute @a"+PlayerSelect+" ~ ~ ~ execute @s[scores={"+ScoreboardName+"="+str(int((a+2)*5+int(Notes[i][1]*5)))+"}] ~ ~ ~ playsound "+Instrument+" @s ~ ~ ~ 1000 "+str(Notes[i][0])+" 1000\n")
|
commands.append("execute @a" + PlayerSelect + " ~ ~ ~ execute @s[scores={" + ScoreboardName + "=" + str(
|
||||||
|
int((a + 2) * 5 + int(Notes[i][1] * 5))) + "}] ~ ~ ~ playsound " + Instrument + " @s ~ ~ ~ 1000 " + str(
|
||||||
|
Notes[i][0]) + " 1000\n")
|
||||||
a += Notes[i][1]
|
a += Notes[i][1]
|
||||||
if isProsess:
|
if isProsess:
|
||||||
commands.append("execute @a"+PlayerSelect+" ~ ~ ~ execute @s[scores={"+ScoreboardName+"="+str(int((a+2)*5+int(Notes[i][1]*5)))+"}] ~ ~ ~ title @s actionbar §e▶ 播放中: §a"+str(j)+"/"+str(length)+" || "+str(int(j/length*1000)/10)+"\n")
|
commands.append("execute @a" + PlayerSelect + " ~ ~ ~ execute @s[scores={" + ScoreboardName + "=" + str(
|
||||||
|
int((a + 2) * 5 + int(Notes[i][1] * 5))) + "}] ~ ~ ~ title @s actionbar §e▶ 播放中: §a" + str(
|
||||||
|
j) + "/" + str(length) + " || " + str(int(j / length * 1000) / 10) + "\n")
|
||||||
j += 1
|
j += 1
|
||||||
commands.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿)\n")
|
commands.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿)\n")
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import amulet
|
|
||||||
import amulet_nbt
|
|
||||||
from amulet.api.block import Block
|
|
||||||
from amulet.api.block_entity import BlockEntity
|
|
||||||
from amulet.utils.world_utils import block_coords_to_chunk_coords
|
|
||||||
from amulet_nbt import TAG_String,TAG_Compound,TAG_Byte
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 简单载入方块
|
# 简单载入方块
|
||||||
# level.set_version_block(posx,posy,posz,"minecraft:overworld",("bedrock", (1, 16, 20)),Block(namespace, name))
|
# level.set_version_block(posx,posy,posz,"minecraft:overworld",("bedrock", (1, 16, 20)),Block(namespace, name))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 转入指令列表与位置信息转至世界
|
# 转入指令列表与位置信息转至世界
|
||||||
def Cmd2World(cmd: list, world: str, dire: list):
|
def Cmd2World(cmd: list, world: str, dire: list):
|
||||||
'''将指令以命令链的形式载入世界\n
|
"""将指令以命令链的形式载入世界\n
|
||||||
cmd指令列表位为一个序列,中包含指令字符串\n
|
cmd指令列表位为一个序列,中包含指令字符串\n
|
||||||
world为地图所在位置,需要指向文件夹,dire为指令方块生成之位置'''
|
world为地图所在位置,需要指向文件夹,dire为指令方块生成之位置"""
|
||||||
level = amulet.load_level(world)
|
level = amulet.load_level(world)
|
||||||
cdl = []
|
cdl = []
|
||||||
for i in cmd:
|
for i in cmd:
|
||||||
|
e = True
|
||||||
try:
|
try:
|
||||||
if (i[:i.index('#')].replace(' ', '') != '\n') and (i[:i.index('#')].replace(' ', '') != ''):
|
if (i[:i.index('#')].replace(' ', '') != '\n') and (i[:i.index('#')].replace(' ', '') != ''):
|
||||||
cdl.append(i[:i.index('#')])
|
cdl.append(i[:i.index('#')])
|
||||||
except:
|
e = False
|
||||||
|
except ValueError:
|
||||||
|
cdl.append(i)
|
||||||
|
finally:
|
||||||
|
if e is True:
|
||||||
cdl.append(i)
|
cdl.append(i)
|
||||||
i = 0
|
i = 0
|
||||||
# 第一个是特殊
|
# 第一个是特殊
|
||||||
universal_block = Block('universal_minecraft','command_block',{'conditional':TAG_String("false"),'facing':TAG_String('up'),'mode':TAG_String("repeating")})
|
universal_block = Block('universal_minecraft', 'command_block',
|
||||||
|
{'conditional': TAG_String("false"), 'facing': TAG_String('up'),
|
||||||
|
'mode': TAG_String("repeating")})
|
||||||
cx, cz = block_coords_to_chunk_coords(dire[0], dire[2])
|
cx, cz = block_coords_to_chunk_coords(dire[0], dire[2])
|
||||||
chunk = level.get_chunk(cx, cz, "minecraft:overworld")
|
chunk = level.get_chunk(cx, cz, "minecraft:overworld")
|
||||||
offset_x, offset_z = dire[0] - 16 * cx, dire[2] - 16 * cz
|
offset_x, offset_z = dire[0] - 16 * cx, dire[2] - 16 * cz
|
||||||
universal_block_entity = BlockEntity( 'universal_minecraft','command_block',dire[0],dire[1],dire[2],amulet_nbt.NBTFile(TAG_Compound({'utags': TAG_Compound({'auto': TAG_Byte(0),'Command': TAG_String(cdl.pop(0))}) })))
|
universal_block_entity = BlockEntity('universal_minecraft', 'command_block', dire[0], dire[1], dire[2],
|
||||||
|
amulet_nbt.NBTFile(TAG_Compound({'utags': TAG_Compound(
|
||||||
|
{'auto': TAG_Byte(0), 'Command': TAG_String(cdl.pop(0))})})))
|
||||||
chunk.blocks[offset_x, dire[1], offset_z] = level.block_palette.get_add_block(universal_block)
|
chunk.blocks[offset_x, dire[1], offset_z] = level.block_palette.get_add_block(universal_block)
|
||||||
chunk.block_entities[(dire[0], dire[1], dire[2])] = universal_block_entity
|
chunk.block_entities[(dire[0], dire[1], dire[2])] = universal_block_entity
|
||||||
chunk.changed = True
|
chunk.changed = True
|
||||||
@ -157,26 +152,36 @@ def Cmd2World(cmd:list,world:str,dire:list):
|
|||||||
down = not down
|
down = not down
|
||||||
# 定义此方块
|
# 定义此方块
|
||||||
if dire[1] + i == 254:
|
if dire[1] + i == 254:
|
||||||
universal_block = Block('universal_minecraft','command_block',{'conditional':TAG_String("false"),'facing':TAG_String('east'),'mode':TAG_String("chain")})
|
universal_block = Block('universal_minecraft', 'command_block',
|
||||||
|
{'conditional': TAG_String("false"), 'facing': TAG_String('east'),
|
||||||
|
'mode': TAG_String("chain")})
|
||||||
else:
|
else:
|
||||||
if down:
|
if down:
|
||||||
universal_block = Block('universal_minecraft','command_block',{'conditional':TAG_String("false"),'facing':TAG_String('down'),'mode':TAG_String("chain")})
|
universal_block = Block('universal_minecraft', 'command_block',
|
||||||
|
{'conditional': TAG_String("false"), 'facing': TAG_String('down'),
|
||||||
|
'mode': TAG_String("chain")})
|
||||||
else:
|
else:
|
||||||
universal_block = Block('universal_minecraft','command_block',{'conditional':TAG_String("false"),'facing':TAG_String('up'),'mode':TAG_String("chain")})
|
universal_block = Block('universal_minecraft', 'command_block',
|
||||||
|
{'conditional': TAG_String("false"), 'facing': TAG_String('up'),
|
||||||
|
'mode': TAG_String("chain")})
|
||||||
cx, cz = block_coords_to_chunk_coords(dire[0], dire[2])
|
cx, cz = block_coords_to_chunk_coords(dire[0], dire[2])
|
||||||
# 获取区块
|
# 获取区块
|
||||||
chunk = level.get_chunk(cx, cz, "minecraft:overworld")
|
chunk = level.get_chunk(cx, cz, "minecraft:overworld")
|
||||||
offset_x, offset_z = dire[0] - 16 * cx, dire[2] - 16 * cz
|
offset_x, offset_z = dire[0] - 16 * cx, dire[2] - 16 * cz
|
||||||
if down:
|
if down:
|
||||||
# 定义方块实体
|
# 定义方块实体
|
||||||
universal_block_entity = BlockEntity( 'universal_minecraft','command_block',dire[0],254-i,dire[2],amulet_nbt.NBTFile(TAG_Compound({'utags': TAG_Compound({'auto': TAG_Byte(1),'Command': TAG_String(j)}) })))
|
universal_block_entity = BlockEntity('universal_minecraft', 'command_block', dire[0], 254 - i, dire[2],
|
||||||
|
amulet_nbt.NBTFile(TAG_Compound({'utags': TAG_Compound(
|
||||||
|
{'auto': TAG_Byte(1), 'Command': TAG_String(j)})})))
|
||||||
|
|
||||||
# 将方块加入世界
|
# 将方块加入世界
|
||||||
chunk.blocks[offset_x, 254 - i, offset_z] = level.block_palette.get_add_block(universal_block)
|
chunk.blocks[offset_x, 254 - i, offset_z] = level.block_palette.get_add_block(universal_block)
|
||||||
chunk.block_entities[(dire[0], 254 - i, dire[2])] = universal_block_entity
|
chunk.block_entities[(dire[0], 254 - i, dire[2])] = universal_block_entity
|
||||||
else:
|
else:
|
||||||
# 定义方块实体
|
# 定义方块实体
|
||||||
universal_block_entity = BlockEntity( 'universal_minecraft','command_block',dire[0],dire[1]+i,dire[2],amulet_nbt.NBTFile(TAG_Compound({'utags': TAG_Compound({'auto': TAG_Byte(1),'Command': TAG_String(j)}) })))
|
universal_block_entity = BlockEntity('universal_minecraft', 'command_block', dire[0], dire[1] + i, dire[2],
|
||||||
|
amulet_nbt.NBTFile(TAG_Compound({'utags': TAG_Compound(
|
||||||
|
{'auto': TAG_Byte(1), 'Command': TAG_String(j)})})))
|
||||||
|
|
||||||
# 将方块加入世界
|
# 将方块加入世界
|
||||||
chunk.blocks[offset_x, dire[1] + i, offset_z] = level.block_palette.get_add_block(universal_block)
|
chunk.blocks[offset_x, dire[1] + i, offset_z] = level.block_palette.get_add_block(universal_block)
|
||||||
@ -190,23 +195,20 @@ def Cmd2World(cmd:list,world:str,dire:list):
|
|||||||
level.close()
|
level.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 音符转成方块再加载到世界里头
|
# 音符转成方块再加载到世界里头
|
||||||
def Blocks2World(world: str, dire: list, Datas: list):
|
def Blocks2World(world: str, dire: list, Datas: list):
|
||||||
from nmcsup.const import Blocks
|
from nmcsup.const import Blocks
|
||||||
level = amulet.load_level(world)
|
level = amulet.load_level(world)
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
def setblock(block: str, pos: list):
|
def setblock(block: str, pos: list):
|
||||||
'''pos : list[int,int,int]'''
|
"""pos : list[int,int,int]"""
|
||||||
cx, cz = block_coords_to_chunk_coords(pos[0], pos[2])
|
cx, cz = block_coords_to_chunk_coords(pos[0], pos[2])
|
||||||
chunk = level.get_chunk(cx, cz, "minecraft:overworld")
|
chunk = level.get_chunk(cx, cz, "minecraft:overworld")
|
||||||
offset_x, offset_z = pos[0] - 16 * cx, pos[2] - 16 * cz
|
offset_x, offset_z = pos[0] - 16 * cx, pos[2] - 16 * cz
|
||||||
chunk.blocks[offset_x, pos[1], offset_z] = level.block_palette.get_add_block(Block("minecraft", block))
|
chunk.blocks[offset_x, pos[1], offset_z] = level.block_palette.get_add_block(Block("minecraft", block))
|
||||||
chunk.changed = True
|
chunk.changed = True
|
||||||
|
|
||||||
for j in Datas:
|
for j in Datas:
|
||||||
if dire[1] + 1 >= 255:
|
if dire[1] + 1 >= 255:
|
||||||
i = 0
|
i = 0
|
||||||
@ -217,16 +219,9 @@ def Blocks2World(world:str,dire:list,Datas:list):
|
|||||||
level.close()
|
level.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 传入音符列表制作播放器指令
|
# 传入音符列表制作播放器指令
|
||||||
def Notes2Player(Note, dire: list, CmdData: dict):
|
def Notes2Player(Note, dire: list, CmdData: dict):
|
||||||
'''传入音符列表、坐标、指令数据,生成播放器指令'''
|
"""传入音符列表、坐标、指令数据,生成播放器指令"""
|
||||||
Notes = {}
|
Notes = {}
|
||||||
for i in Note:
|
for i in Note:
|
||||||
Notes[i[0]] = ''
|
Notes[i[0]] = ''
|
||||||
@ -234,21 +229,17 @@ def Notes2Player(Note,dire:list,CmdData:dict):
|
|||||||
from nmcsup.const import Blocks
|
from nmcsup.const import Blocks
|
||||||
Cmds = []
|
Cmds = []
|
||||||
for j in Notes:
|
for j in Notes:
|
||||||
Cmds.append('execute @e[x='+str(dire[0])+',y='+str(dire[1])+',z='+str(dire[2])+',dy='+str(255-dire[1])+',name='+CmdData['Ent']+'] ~ ~ ~ detect ~ ~ ~ '+Blocks[j]+' 0 execute @a '+CmdData['Pls']+' ~ ~ ~ playsound '+CmdData['Ins']+' @s ~ ~ ~ 1000 '+str(j)+' 1000\n')
|
Cmds.append('execute @e[x=' + str(dire[0]) + ',y=' + str(dire[1]) + ',z=' + str(dire[2]) + ',dy=' + str(
|
||||||
Cmds+=['#本函数由 金羿 音·创 生成\n','execute @e[y='+str(dire[1])+',dy='+str(255-dire[1])+',name='+CmdData['Ent']+'] ~ ~ ~ tp ~ ~1 ~\n','execute @e[y=255,dy=100,name='+CmdData['Ent']+'] ~ ~ ~ tp ~1 '+str(dire[1])+' ~\n','#音·创 开发交流群 861684859']
|
255 - dire[1]) + ',name=' + CmdData['Ent'] + '] ~ ~ ~ detect ~ ~ ~ ' + Blocks[j] + ' 0 execute @a ' +
|
||||||
|
CmdData['Pls'] + ' ~ ~ ~ playsound ' + CmdData['Ins'] + ' @s ~ ~ ~ 1000 ' + str(j) + ' 1000\n')
|
||||||
|
Cmds += ['#本函数由 金羿 音·创 生成\n', 'execute @e[y=' + str(dire[1]) + ',dy=' + str(255 - dire[1]) + ',name=' + CmdData[
|
||||||
|
'Ent'] + '] ~ ~ ~ tp ~ ~1 ~\n',
|
||||||
|
'execute @e[y=255,dy=100,name=' + CmdData['Ent'] + '] ~ ~ ~ tp ~1 ' + str(dire[1]) + ' ~\n',
|
||||||
|
'#音·创 开发交流群 861684859']
|
||||||
return Cmds
|
return Cmds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 传入音符列表生成方块至世界
|
# 传入音符列表生成方块至世界
|
||||||
def Datas2BlkWorld(NoteData, world: str, dire: list):
|
def Datas2BlkWorld(NoteData, world: str, dire: list):
|
||||||
for i in range(len(NoteData)):
|
for i in range(len(NoteData)):
|
||||||
Blocks2World(world, [dire[0], dire[1], dire[2] + i], NoteData[i])
|
Blocks2World(world, [dire[0], dire[1], dire[2] + i], NoteData[i])
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
"""音创系列版本号和版本操作函数"""
|
"""音创系列版本号和版本操作函数"""
|
||||||
|
# 统计:致命(三级)错误:0个;警告(二级)错误:0个;语法(一级)错误:24个
|
||||||
|
|
||||||
|
|
||||||
from msctspt.bugReporter import version
|
from msctspt.bugReporter import version
|
||||||
|
import os
|
||||||
|
|
||||||
# 以下下两个值请在 msctspt/bugReporter 的version类中修改
|
# 以下下两个值请在 msctspt/bugReporter 的version类中修改
|
||||||
VER = version.version
|
VER = version.version
|
||||||
'''当前版本'''
|
"""当前版本"""
|
||||||
|
|
||||||
LIBS = version.libraries
|
LIBS = version.libraries
|
||||||
'''当前所需库'''
|
"""当前所需库"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 判断版本、临时文件与补全库
|
# 判断版本、临时文件与补全库
|
||||||
@ -39,6 +38,8 @@ def compver(ver1, ver2):
|
|||||||
return -1
|
return -1
|
||||||
else:
|
else:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# ————————————————
|
# ————————————————
|
||||||
# 版权声明:上面的函数compver为CSDN博主「基友死得早」的原创文章中的函数,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
|
# 版权声明:上面的函数compver为CSDN博主「基友死得早」的原创文章中的函数,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
|
||||||
@ -46,19 +47,18 @@ def compver(ver1, ver2):
|
|||||||
# ————————————————
|
# ————————————————
|
||||||
#
|
#
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
def InstallLibs(now,LIBS):
|
def InstallLibs(now, LIBS1):
|
||||||
'''比对库信息并安装库'''
|
"""比对库信息并安装库"""
|
||||||
from os import system as run
|
from os import system as run
|
||||||
for i in LIBS:
|
for i in LIBS1:
|
||||||
if not i in now:
|
if i not in now:
|
||||||
print("安装库:" + i)
|
print("安装库:" + i)
|
||||||
run("python -m pip install " + i + " -i https://pypi.tuna.tsinghua.edu.cn/simple")
|
run("python -m pip install " + i + " -i https://pypi.tuna.tsinghua.edu.cn/simple")
|
||||||
|
|
||||||
|
|
||||||
def chkver(ver=VER, libs=LIBS):
|
def chkver(ver=VER, libs=LIBS):
|
||||||
'''通过文件比对版本信息并安装库'''
|
"""通过文件比对版本信息并安装库"""
|
||||||
if not os.path.exists(os.getenv('APPDATA') + '\\Musicreater\\msct.ActiveDatas.msct'):
|
if not os.path.exists(os.getenv('APPDATA') + '\\Musicreater\\msct.ActiveDatas.msct'):
|
||||||
print("新安装库")
|
print("新安装库")
|
||||||
os.makedirs(os.getenv('APPDATA') + '\\Musicreater\\')
|
os.makedirs(os.getenv('APPDATA') + '\\Musicreater\\')
|
||||||
@ -81,9 +81,6 @@ def chkver(ver = VER,libs = LIBS):
|
|||||||
|
|
||||||
|
|
||||||
def resetver():
|
def resetver():
|
||||||
'''重置版本信息'''
|
"""重置版本信息"""
|
||||||
import shutil
|
import shutil
|
||||||
shutil.rmtree(os.getenv('APPDATA') + '\\Musicreater\\')
|
shutil.rmtree(os.getenv('APPDATA') + '\\Musicreater\\')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user