mcf-mot 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcf_mot-2.1.0/LICENSE +21 -0
- mcf_mot-2.1.0/PKG-INFO +13 -0
- mcf_mot-2.1.0/README.md +2 -0
- mcf_mot-2.1.0/pyproject.toml +18 -0
- mcf_mot-2.1.0/setup.cfg +4 -0
- mcf_mot-2.1.0/src/mcf_mot/__init__.py +0 -0
- mcf_mot-2.1.0/src/mcf_mot/create_datapack.py +44 -0
- mcf_mot-2.1.0/src/mcf_mot/create_mcfo.py +51 -0
- mcf_mot-2.1.0/src/mcf_mot/create_mot.py +13 -0
- mcf_mot-2.1.0/src/mcf_mot/memory_stack.py +422 -0
- mcf_mot-2.1.0/src/mcf_mot/print_plates.py +21 -0
- mcf_mot-2.1.0/src/mcf_mot.egg-info/PKG-INFO +13 -0
- mcf_mot-2.1.0/src/mcf_mot.egg-info/SOURCES.txt +14 -0
- mcf_mot-2.1.0/src/mcf_mot.egg-info/dependency_links.txt +1 -0
- mcf_mot-2.1.0/src/mcf_mot.egg-info/entry_points.txt +2 -0
- mcf_mot-2.1.0/src/mcf_mot.egg-info/top_level.txt +1 -0
mcf_mot-2.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 xiaodou8593
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
mcf_mot-2.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcf_mot
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: Mcfunction Object Template
|
|
5
|
+
Author-email: xiaodou123 <x859345316@163.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# mot_2.1
|
|
13
|
+
Mcfunction Object Template
|
mcf_mot-2.1.0/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
# 告诉pip使用setuptools来构建你的项目
|
|
3
|
+
requires = ["setuptools >= 77.0.3"]
|
|
4
|
+
build-backend = "setuptools.build_meta"
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
# 项目的元数据
|
|
8
|
+
name = "mcf_mot" # 这是用户用pip install的名字
|
|
9
|
+
version = "2.1.0"
|
|
10
|
+
description = "Mcfunction Object Template"
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
authors = [{ name = "xiaodou123", email = "x859345316@163.com" }]
|
|
13
|
+
license = { text = "MIT" } # 选择你喜欢的许可证
|
|
14
|
+
requires-python = ">=3.8"
|
|
15
|
+
dependencies = []
|
|
16
|
+
|
|
17
|
+
[project.scripts]
|
|
18
|
+
mot = "mcf_mot.memory_stack:main"
|
mcf_mot-2.1.0/setup.cfg
ADDED
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import ctypes
|
|
4
|
+
import ctypes.wintypes
|
|
5
|
+
|
|
6
|
+
def close_file_explorer():
|
|
7
|
+
# 查找文件资源管理器窗口
|
|
8
|
+
hwnd = ctypes.windll.user32.FindWindowW("CabinetWClass", None)
|
|
9
|
+
if hwnd:
|
|
10
|
+
# 发送关闭消息
|
|
11
|
+
ctypes.windll.user32.PostMessageW(hwnd, 0x0010, 0, 0) # WM_CLOSE
|
|
12
|
+
print("当前文件资源管理器窗口已关闭")
|
|
13
|
+
else:
|
|
14
|
+
print("未找到文件资源管理器窗口")
|
|
15
|
+
|
|
16
|
+
data_versions = {}
|
|
17
|
+
|
|
18
|
+
name = input("输入数据包名称:")
|
|
19
|
+
if name == '#':
|
|
20
|
+
sys.exit(0)
|
|
21
|
+
namespace = input("请输入命名空间:")
|
|
22
|
+
if namespace == '#':
|
|
23
|
+
sys.exit(0)
|
|
24
|
+
|
|
25
|
+
path = [name, 'data', namespace, 'function']
|
|
26
|
+
try:
|
|
27
|
+
os.makedirs('/'.join(path))
|
|
28
|
+
except:
|
|
29
|
+
pass
|
|
30
|
+
file = open(f'{name}/pack.mcmeta', 'w', encoding='utf-8')
|
|
31
|
+
file.write('''
|
|
32
|
+
{
|
|
33
|
+
"pack":{
|
|
34
|
+
"description": "version- by-",
|
|
35
|
+
"pack_format": 71,
|
|
36
|
+
"supported_formats": [71, 107],
|
|
37
|
+
"min_format": 71,
|
|
38
|
+
"max_format": [107, 1]
|
|
39
|
+
}
|
|
40
|
+
}''')
|
|
41
|
+
file.close()
|
|
42
|
+
|
|
43
|
+
close_file_explorer()
|
|
44
|
+
os.startfile(f'{name}\\data\\{namespace}\\function')
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
# 模块文件夹预设
|
|
5
|
+
current_dir = os.getcwd().split('\\')
|
|
6
|
+
# 搜索模块的命名空间和路径
|
|
7
|
+
anchor_found = False
|
|
8
|
+
sub_folders = []
|
|
9
|
+
for folder in current_dir[::-1]:
|
|
10
|
+
|
|
11
|
+
# 找到functions/function文件夹停止
|
|
12
|
+
if folder in ('functions', 'function'):
|
|
13
|
+
anchor_found = True
|
|
14
|
+
continue
|
|
15
|
+
|
|
16
|
+
# functions以外文件夹的处理
|
|
17
|
+
if anchor_found:
|
|
18
|
+
namespace = folder
|
|
19
|
+
break
|
|
20
|
+
else:
|
|
21
|
+
sub_folders.insert(0, folder)
|
|
22
|
+
if not anchor_found:
|
|
23
|
+
print("路径不满足要求!")
|
|
24
|
+
time.sleep(5)
|
|
25
|
+
raise ValueError('path error')
|
|
26
|
+
# 生成函数前缀
|
|
27
|
+
prefix = f'{namespace}:' + '/'.join(sub_folders)
|
|
28
|
+
if sub_folders:
|
|
29
|
+
prefix += '/'
|
|
30
|
+
|
|
31
|
+
module_name = namespace
|
|
32
|
+
if sub_folders:
|
|
33
|
+
module_name = sub_folders[-1]
|
|
34
|
+
|
|
35
|
+
this_fill = """_this:{
|
|
36
|
+
|
|
37
|
+
}"""
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
with open('.mot_memory/templates/.doc.mcfo', 'r', encoding='utf-8') as file:
|
|
41
|
+
this_fill = file.read()
|
|
42
|
+
except:
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
file = open('.doc.mcfo', 'w', encoding='utf-8')
|
|
46
|
+
content = """#{}doc.mcfo
|
|
47
|
+
|
|
48
|
+
# {}临时对象
|
|
49
|
+
{}""".format(prefix,module_name,this_fill)
|
|
50
|
+
file.write(content)
|
|
51
|
+
file.close()
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import time
|
|
4
|
+
import ctypes
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
def print_folder_structure(path, indent=" ", show_files=True, ignore_dirs=None, level=0):
|
|
10
|
+
"""
|
|
11
|
+
递归打印指定文件夹的结构。
|
|
12
|
+
|
|
13
|
+
参数:
|
|
14
|
+
path (str): 要打印的文件夹路径。
|
|
15
|
+
indent (str): 每级缩进使用的字符串,默认为两个空格。
|
|
16
|
+
show_files (bool): 是否显示文件名,默认为 True。
|
|
17
|
+
ignore_dirs (list): 要忽略的文件夹名称列表,默认为 None。
|
|
18
|
+
level (int): 内部使用的递归层级,调用时无需指定。
|
|
19
|
+
"""
|
|
20
|
+
if ignore_dirs is None:
|
|
21
|
+
ignore_dirs = []
|
|
22
|
+
|
|
23
|
+
# 检查路径是否存在且为目录
|
|
24
|
+
if not os.path.exists(path):
|
|
25
|
+
print(f"错误:路径 '{path}' 不存在")
|
|
26
|
+
return
|
|
27
|
+
if not os.path.isdir(path):
|
|
28
|
+
print(f"错误:'{path}' 不是一个文件夹")
|
|
29
|
+
return
|
|
30
|
+
|
|
31
|
+
# 获取当前文件夹名称并打印(根目录特殊处理)
|
|
32
|
+
base_name = os.path.basename(os.path.normpath(path))
|
|
33
|
+
if level == 0:
|
|
34
|
+
print(base_name + "/")
|
|
35
|
+
else:
|
|
36
|
+
print(indent * (level - 1) + "|-- " + base_name + "/")
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
items = sorted(os.listdir(path)) # 排序以保持输出一致
|
|
40
|
+
except PermissionError:
|
|
41
|
+
print(indent * level + "|-- [权限不足,无法访问]")
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
for item in items:
|
|
45
|
+
# 跳过隐藏文件和文件夹(以 . 开头),如果需要显示可注释掉
|
|
46
|
+
# if item.startswith('.'):
|
|
47
|
+
# continue
|
|
48
|
+
|
|
49
|
+
item_path = os.path.join(path, item)
|
|
50
|
+
|
|
51
|
+
# 如果是目录且不在忽略列表中,递归处理
|
|
52
|
+
if os.path.isdir(item_path):
|
|
53
|
+
if item in ignore_dirs:
|
|
54
|
+
continue
|
|
55
|
+
print_folder_structure(item_path, indent, show_files, ignore_dirs, level + 1)
|
|
56
|
+
else:
|
|
57
|
+
# 如果是文件且允许显示
|
|
58
|
+
if show_files:
|
|
59
|
+
print(indent * level + "|-- " + item)
|
|
60
|
+
|
|
61
|
+
def find_datapacks_directory():
|
|
62
|
+
"""从当前目录向上查找名为datapacks的目录"""
|
|
63
|
+
current_path = Path.cwd()
|
|
64
|
+
|
|
65
|
+
# 从当前目录开始向上遍历
|
|
66
|
+
temp_cnt = 0
|
|
67
|
+
while current_path != current_path.root:
|
|
68
|
+
if temp_cnt > 50:
|
|
69
|
+
return None
|
|
70
|
+
# 检查当前目录是否是datapacks
|
|
71
|
+
if current_path.name == 'datapacks':
|
|
72
|
+
return current_path
|
|
73
|
+
|
|
74
|
+
# 检查当前目录的子目录中是否有datapacks
|
|
75
|
+
for child in current_path.iterdir():
|
|
76
|
+
if child.is_dir() and child.name == 'datapacks':
|
|
77
|
+
return child
|
|
78
|
+
|
|
79
|
+
# 向上移动一级目录
|
|
80
|
+
current_path = current_path.parent
|
|
81
|
+
temp_cnt += 1
|
|
82
|
+
|
|
83
|
+
return None
|
|
84
|
+
|
|
85
|
+
def find_folders_with_memory_storage(datapacks_path):
|
|
86
|
+
"""在datapacks目录中查找包含memory_storage子文件夹的文件夹"""
|
|
87
|
+
folders_with_memory_storage = []
|
|
88
|
+
|
|
89
|
+
if not datapacks_path or not datapacks_path.exists():
|
|
90
|
+
return folders_with_memory_storage
|
|
91
|
+
|
|
92
|
+
# 遍历datapacks目录下的所有项目
|
|
93
|
+
for item in datapacks_path.iterdir():
|
|
94
|
+
if item.is_dir():
|
|
95
|
+
# 检查该文件夹是否包含memory_storage子文件夹
|
|
96
|
+
memory_storage_path = item / 'memory_storage'
|
|
97
|
+
if memory_storage_path.exists() and memory_storage_path.is_dir():
|
|
98
|
+
folders_with_memory_storage.append(item)
|
|
99
|
+
|
|
100
|
+
return folders_with_memory_storage
|
|
101
|
+
|
|
102
|
+
ex_paths = []
|
|
103
|
+
# 查找datapacks目录
|
|
104
|
+
datapacks_path = find_datapacks_directory()
|
|
105
|
+
if datapacks_path:
|
|
106
|
+
# 查找包含memory_storage的文件夹
|
|
107
|
+
folders = find_folders_with_memory_storage(datapacks_path)
|
|
108
|
+
if folders:
|
|
109
|
+
for folder in folders:
|
|
110
|
+
ex_paths.append(f"{folder.absolute()}")
|
|
111
|
+
|
|
112
|
+
# 模块文件夹预设
|
|
113
|
+
current_dir = os.getcwd().split('\\')
|
|
114
|
+
# 搜索模块的命名空间和路径
|
|
115
|
+
anchor_found = False
|
|
116
|
+
sub_folders = []
|
|
117
|
+
for folder in current_dir[::-1]:
|
|
118
|
+
|
|
119
|
+
# 找到functions/function文件夹停止
|
|
120
|
+
if folder in ('functions', 'function'):
|
|
121
|
+
anchor_found = True
|
|
122
|
+
continue
|
|
123
|
+
|
|
124
|
+
# functions以外文件夹的处理
|
|
125
|
+
if anchor_found:
|
|
126
|
+
namespace = folder
|
|
127
|
+
break
|
|
128
|
+
else:
|
|
129
|
+
sub_folders.insert(0, folder)
|
|
130
|
+
if not anchor_found:
|
|
131
|
+
print("路径不满足要求!")
|
|
132
|
+
time.sleep(5)
|
|
133
|
+
raise ValueError('path error')
|
|
134
|
+
|
|
135
|
+
# 获取路径参数
|
|
136
|
+
module_path = os.getcwd()
|
|
137
|
+
lib_path = sys.argv[0]
|
|
138
|
+
|
|
139
|
+
def folder_to_memory(folder_path):
|
|
140
|
+
"""将文件夹内容读取到内存"""
|
|
141
|
+
folder_data = {}
|
|
142
|
+
|
|
143
|
+
for root, dirs, files in os.walk(folder_path):
|
|
144
|
+
# 处理目录结构
|
|
145
|
+
relative_path = os.path.relpath(root, folder_path)
|
|
146
|
+
if relative_path == '.':
|
|
147
|
+
relative_path = ''
|
|
148
|
+
|
|
149
|
+
# 读取文件内容
|
|
150
|
+
for file in files:
|
|
151
|
+
file_path = os.path.join(root, file)
|
|
152
|
+
relative_file_path = os.path.join(relative_path, file) if relative_path else file
|
|
153
|
+
|
|
154
|
+
with open(file_path, 'rb') as f:
|
|
155
|
+
folder_data[relative_file_path] = f.read()
|
|
156
|
+
|
|
157
|
+
return folder_data
|
|
158
|
+
|
|
159
|
+
def memory_to_folder(folder_data, output_path):
|
|
160
|
+
"""将内存中的数据还原为文件夹"""
|
|
161
|
+
# 确保输出目录存在
|
|
162
|
+
os.makedirs(output_path, exist_ok=True)
|
|
163
|
+
|
|
164
|
+
for relative_path, content in folder_data.items():
|
|
165
|
+
file_path = os.path.join(output_path, relative_path)
|
|
166
|
+
|
|
167
|
+
# 确保目录存在
|
|
168
|
+
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
|
169
|
+
|
|
170
|
+
# 写入文件内容
|
|
171
|
+
with open(file_path, 'wb') as f:
|
|
172
|
+
f.write(content)
|
|
173
|
+
|
|
174
|
+
def merge_folders(src_folder, dst_folder):
|
|
175
|
+
"""
|
|
176
|
+
将源文件夹内容合并到目标文件夹
|
|
177
|
+
"""
|
|
178
|
+
if not os.path.exists(dst_folder):
|
|
179
|
+
os.makedirs(dst_folder)
|
|
180
|
+
|
|
181
|
+
for item in os.listdir(src_folder):
|
|
182
|
+
src_path = os.path.join(src_folder, item)
|
|
183
|
+
dst_path = os.path.join(dst_folder, item)
|
|
184
|
+
|
|
185
|
+
if os.path.isdir(src_path):
|
|
186
|
+
# 如果是文件夹,递归合并
|
|
187
|
+
if os.path.exists(dst_path) and os.path.isdir(dst_path):
|
|
188
|
+
merge_folders(src_path, dst_path)
|
|
189
|
+
else:
|
|
190
|
+
shutil.copytree(src_path, dst_path)
|
|
191
|
+
else:
|
|
192
|
+
# 如果是文件,复制文件
|
|
193
|
+
shutil.copy2(src_path, dst_path)
|
|
194
|
+
|
|
195
|
+
def delete_folder(folder_path):
|
|
196
|
+
"""
|
|
197
|
+
删除文件夹
|
|
198
|
+
"""
|
|
199
|
+
try:
|
|
200
|
+
os.rmdir(folder_path)
|
|
201
|
+
except:
|
|
202
|
+
try:
|
|
203
|
+
shutil.rmtree(folder_path)
|
|
204
|
+
except:
|
|
205
|
+
pass
|
|
206
|
+
|
|
207
|
+
# 修改终端标题
|
|
208
|
+
def modify_title():
|
|
209
|
+
title = f'[.memory_stack.py - {os.getcwd()}]'
|
|
210
|
+
try:
|
|
211
|
+
ctypes.windll.kernel32.SetConsoleTitleW(title)
|
|
212
|
+
except Exception:
|
|
213
|
+
pass # 如果失败则静默处理
|
|
214
|
+
modify_title()
|
|
215
|
+
|
|
216
|
+
# 记忆模板的数据结构
|
|
217
|
+
lst_memories = []
|
|
218
|
+
# 读取储存的记忆模板
|
|
219
|
+
def read_memories():
|
|
220
|
+
"""
|
|
221
|
+
查找指定目录下的直接子文件夹(不包含子文件夹的子文件夹)
|
|
222
|
+
"""
|
|
223
|
+
global lst_memories
|
|
224
|
+
folders = []
|
|
225
|
+
directory = lib_path+'\\memory_storage'
|
|
226
|
+
for item in os.listdir(directory):
|
|
227
|
+
item_path = os.path.join(directory, item)
|
|
228
|
+
if os.path.isdir(item_path):
|
|
229
|
+
folders.append(item)
|
|
230
|
+
lst_memories = folders
|
|
231
|
+
print(f'read {len(lst_memories)} memories.')
|
|
232
|
+
read_memories()
|
|
233
|
+
|
|
234
|
+
# 储存当前记忆
|
|
235
|
+
def save_memory():
|
|
236
|
+
if stack[-1] is None:
|
|
237
|
+
print("无法储存空记忆")
|
|
238
|
+
return
|
|
239
|
+
while True:
|
|
240
|
+
memory_name = input('请为记忆模板命名:')
|
|
241
|
+
if memory_name in lst_memories:
|
|
242
|
+
print('命名不能与现有名字重复')
|
|
243
|
+
elif memory_name == '#':
|
|
244
|
+
print('cancelled.')
|
|
245
|
+
return
|
|
246
|
+
break
|
|
247
|
+
input_path = lib_path + '\\memory_storage\\' + f'{memory_name}'
|
|
248
|
+
os.makedirs(input_path, exist_ok=True)
|
|
249
|
+
memory_to_folder(stack[-1], input_path)
|
|
250
|
+
print(f'memory {memory_name} saved.')
|
|
251
|
+
read_memories()
|
|
252
|
+
|
|
253
|
+
# 输出所有记忆
|
|
254
|
+
def print_memories():
|
|
255
|
+
index = 0
|
|
256
|
+
for _ in range((len(lst_memories)+2)//3):
|
|
257
|
+
line_string = ''
|
|
258
|
+
for __ in range(3):
|
|
259
|
+
if index >= len(lst_memories):
|
|
260
|
+
break
|
|
261
|
+
line_string += f'{index+1}.{lst_memories[index]}\t'
|
|
262
|
+
index += 1
|
|
263
|
+
print((line_string))
|
|
264
|
+
|
|
265
|
+
# 栈的数据结构
|
|
266
|
+
stack = [None]
|
|
267
|
+
# 读取栈顶元素
|
|
268
|
+
def read_stack_top():
|
|
269
|
+
global stack
|
|
270
|
+
stack.pop()
|
|
271
|
+
input_path = module_path + '\\.mot_memory'
|
|
272
|
+
if os.path.exists(input_path) and os.path.isdir(input_path):
|
|
273
|
+
stack.append(folder_to_memory(input_path))
|
|
274
|
+
else:
|
|
275
|
+
stack.append(None)
|
|
276
|
+
print('read memory stack top.')
|
|
277
|
+
read_stack_top()
|
|
278
|
+
|
|
279
|
+
# 栈顶元素同步到文件夹
|
|
280
|
+
def stack_sync_folder():
|
|
281
|
+
input_path = module_path + '\\.mot_memory'
|
|
282
|
+
delete_folder(input_path)
|
|
283
|
+
if stack[-1] is None:
|
|
284
|
+
return
|
|
285
|
+
memory_to_folder(stack[-1], input_path)
|
|
286
|
+
print('memory stack top synced.')
|
|
287
|
+
|
|
288
|
+
# 指定记忆模板入栈
|
|
289
|
+
def push_memory():
|
|
290
|
+
global user_input
|
|
291
|
+
memory_name = user_input[0]
|
|
292
|
+
input_path = lib_path + '\\memory_storage\\' + f'{memory_name}'
|
|
293
|
+
if os.path.exists(input_path) and os.path.isdir(input_path):
|
|
294
|
+
pass
|
|
295
|
+
else:
|
|
296
|
+
bool_flag = True
|
|
297
|
+
for ex_path in ex_paths:
|
|
298
|
+
input_path = ex_path + '\\memory_storage\\' + f'{memory_name}'
|
|
299
|
+
if os.path.exists(input_path) and os.path.isdir(input_path):
|
|
300
|
+
bool_flag = False
|
|
301
|
+
break
|
|
302
|
+
if bool_flag:
|
|
303
|
+
print('memory not exit!')
|
|
304
|
+
return
|
|
305
|
+
stack.append(folder_to_memory(input_path))
|
|
306
|
+
print(f'pushed memory: {memory_name}.')
|
|
307
|
+
stack_sync_folder()
|
|
308
|
+
|
|
309
|
+
# 选择记忆模板入栈
|
|
310
|
+
def stack_push():
|
|
311
|
+
global user_input
|
|
312
|
+
if len(user_input)<2:
|
|
313
|
+
print_memories()
|
|
314
|
+
while True:
|
|
315
|
+
memory_name = input('请选择记忆模板(输入名称):')
|
|
316
|
+
if memory_name == '#':
|
|
317
|
+
print('cancelled.')
|
|
318
|
+
return
|
|
319
|
+
if memory_name in lst_memories:
|
|
320
|
+
break
|
|
321
|
+
print('记忆模板不存在!')
|
|
322
|
+
user_input = [memory_name]
|
|
323
|
+
else:
|
|
324
|
+
user_input = [user_input[1]]
|
|
325
|
+
push_memory()
|
|
326
|
+
|
|
327
|
+
# 向下合并
|
|
328
|
+
def stack_merge():
|
|
329
|
+
if len(stack)<2:
|
|
330
|
+
return
|
|
331
|
+
mem_a = stack.pop()
|
|
332
|
+
mem_b = stack.pop()
|
|
333
|
+
if mem_a is None:
|
|
334
|
+
mem_merge = mem_b
|
|
335
|
+
elif mem_b is None:
|
|
336
|
+
mem_merge = mem_a
|
|
337
|
+
else:
|
|
338
|
+
path_a = lib_path + '\\mem_a'
|
|
339
|
+
path_b = lib_path + '\\mem_b'
|
|
340
|
+
memory_to_folder(mem_a, path_a)
|
|
341
|
+
memory_to_folder(mem_b, path_b)
|
|
342
|
+
merge_folders(path_b, path_a)
|
|
343
|
+
mem_merge = folder_to_memory(path_a)
|
|
344
|
+
delete_folder(path_a)
|
|
345
|
+
delete_folder(path_b)
|
|
346
|
+
stack.append(mem_merge)
|
|
347
|
+
print('memory stack down merge.')
|
|
348
|
+
stack_sync_folder()
|
|
349
|
+
|
|
350
|
+
# 弹出栈顶元素
|
|
351
|
+
def stack_pop():
|
|
352
|
+
stack.pop()
|
|
353
|
+
if len(stack)==0:
|
|
354
|
+
stack.append(None)
|
|
355
|
+
print('memory stack pop.')
|
|
356
|
+
stack_sync_folder()
|
|
357
|
+
|
|
358
|
+
# 创建文件夹
|
|
359
|
+
def create_folder(path):
|
|
360
|
+
try:
|
|
361
|
+
os.makedirs(path,exist_ok=True)
|
|
362
|
+
print(f'created folder: {path}')
|
|
363
|
+
except:
|
|
364
|
+
pass
|
|
365
|
+
def create_folders():
|
|
366
|
+
for path in user_input[1:]:
|
|
367
|
+
create_folder(path)
|
|
368
|
+
|
|
369
|
+
# 删除文件夹
|
|
370
|
+
def destroy_folder(path):
|
|
371
|
+
try:
|
|
372
|
+
shutil.rmtree(path)
|
|
373
|
+
print(f"folder destroyed: {path}")
|
|
374
|
+
except FileNotFoundError:
|
|
375
|
+
print(f"folder not exist: {path}")
|
|
376
|
+
except Exception as e:
|
|
377
|
+
print(e)
|
|
378
|
+
pass
|
|
379
|
+
def destroy_folders():
|
|
380
|
+
for path in user_input[1:]:
|
|
381
|
+
destroy_folder(path)
|
|
382
|
+
|
|
383
|
+
def inspect():
|
|
384
|
+
print_folder_structure('.mot_memory/templates')
|
|
385
|
+
|
|
386
|
+
def stop():
|
|
387
|
+
"""
|
|
388
|
+
结束程序
|
|
389
|
+
"""
|
|
390
|
+
sys.exit(0)
|
|
391
|
+
|
|
392
|
+
def run_mot():
|
|
393
|
+
"""
|
|
394
|
+
运行mot1.1终端
|
|
395
|
+
"""
|
|
396
|
+
print("mot1.1 running.")
|
|
397
|
+
subprocess.run(['python', lib_path+'\\.mot.py'])
|
|
398
|
+
print('mot1.1 exit.')
|
|
399
|
+
modify_title()
|
|
400
|
+
read_stack_top()
|
|
401
|
+
|
|
402
|
+
def main():
|
|
403
|
+
pass
|
|
404
|
+
|
|
405
|
+
print('\n')
|
|
406
|
+
|
|
407
|
+
# 命令映射表
|
|
408
|
+
command_table = {'':run_mot, 'run':run_mot, 'stop':stop, 'save':save_memory}
|
|
409
|
+
command_table |= {'push':stack_push, 'pop':stack_pop, 'merge':stack_merge}
|
|
410
|
+
command_table |= {'mread':read_memories, 'sread':read_stack_top, 'print':print_memories}
|
|
411
|
+
command_table |= {'make':create_folders, 'destroy':destroy_folders, 'inspect':inspect}
|
|
412
|
+
# 主程序
|
|
413
|
+
while True:
|
|
414
|
+
user_input = input().split(' ')
|
|
415
|
+
command = user_input[0]
|
|
416
|
+
if command in command_table:
|
|
417
|
+
command_table[command]()
|
|
418
|
+
elif command in lst_memories:
|
|
419
|
+
push_memory()
|
|
420
|
+
else:
|
|
421
|
+
print(f'未识别命令: {command}')
|
|
422
|
+
print('\n')
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
# 获取当前目录
|
|
4
|
+
current_dir = os.getcwd()
|
|
5
|
+
found_files = []
|
|
6
|
+
|
|
7
|
+
# 遍历当前目录及其所有子目录
|
|
8
|
+
for root, dirs, files in os.walk(current_dir):
|
|
9
|
+
for file in files:
|
|
10
|
+
if file.endswith('.mcfi'):
|
|
11
|
+
# 构建相对路径
|
|
12
|
+
relative_path = os.path.relpath(os.path.join(root, file), current_dir)
|
|
13
|
+
relative_path = relative_path.replace('\\','/').replace('.mcfi','')
|
|
14
|
+
found_files.append(relative_path)
|
|
15
|
+
|
|
16
|
+
if not found_files:
|
|
17
|
+
print("未找到任何.mcfi文件")
|
|
18
|
+
else:
|
|
19
|
+
print(', '.join(found_files))
|
|
20
|
+
|
|
21
|
+
input()
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcf_mot
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: Mcfunction Object Template
|
|
5
|
+
Author-email: xiaodou123 <x859345316@163.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# mot_2.1
|
|
13
|
+
Mcfunction Object Template
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/mcf_mot/__init__.py
|
|
5
|
+
src/mcf_mot/create_datapack.py
|
|
6
|
+
src/mcf_mot/create_mcfo.py
|
|
7
|
+
src/mcf_mot/create_mot.py
|
|
8
|
+
src/mcf_mot/memory_stack.py
|
|
9
|
+
src/mcf_mot/print_plates.py
|
|
10
|
+
src/mcf_mot.egg-info/PKG-INFO
|
|
11
|
+
src/mcf_mot.egg-info/SOURCES.txt
|
|
12
|
+
src/mcf_mot.egg-info/dependency_links.txt
|
|
13
|
+
src/mcf_mot.egg-info/entry_points.txt
|
|
14
|
+
src/mcf_mot.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mcf_mot
|