调整ai数据
This commit is contained in:
1 parent
f8c300a4c6
commit
c2f5cd98ff
493 files changed
+7
-7
No files matched your search
@@ -0,0 +1,120 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""把 sa_core 76 个材料做成网易版 AddOn 物品:beh json + res json + item_texture + zh_CN.lang + 贴图"""
|
||||
import csv, os, json, shutil
|
||||
|
||||
BASE = r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a'
|
||||
BEH = os.path.join(BASE, 'behavior_pack_kcH4M5u0', 'netease_items_beh')
|
||||
RES = os.path.join(BASE, 'resource_pack_t7eJjrxY', 'netease_items_res')
|
||||
TEX = os.path.join(BASE, 'resource_pack_t7eJjrxY', 'textures', 'items')
|
||||
SRC_TEX = os.path.join(BASE, '_sa_material_textures')
|
||||
ITEM_TEX = os.path.join(BASE, 'resource_pack_t7eJjrxY', 'textures', 'item_texture.json')
|
||||
LANG = os.path.join(BASE, 'resource_pack_t7eJjrxY', 'texts', 'zh_CN.lang')
|
||||
|
||||
# 读取材料清单(序号,贴图文件,物品ID,中文名,英文名,路径)
|
||||
mats = []
|
||||
with open(os.path.join(BASE, '_sa_materials.csv'), encoding='utf-8-sig') as f:
|
||||
for row in csv.reader(f):
|
||||
if row and row[1].endswith('.png') and row[0].isdigit():
|
||||
mats.append((row[1][:-4], row[3])) # (name, zh)
|
||||
|
||||
# 描述:特判字典 + 关键词兜底
|
||||
SPECIAL = {
|
||||
'dirty_water_bottle': '饮用可能引起饥饿',
|
||||
'generator_manual': '学习手册并完成实践训练以操作汽油发电机。',
|
||||
'matchbox': '点燃方块和火焰',
|
||||
'sterilized_rags': '清洁医用布。使用后返还脏抹布',
|
||||
'rope': '可放置且可攀爬,落上时可防止摔落伤害',
|
||||
'jerry_can': '用于储存液体:右键液体源收集,Shift+右键倒出',
|
||||
'saw_blade': '锯子部件,用于制作工具',
|
||||
'money': '战利品货币',
|
||||
'money_bundle': '一捆货币',
|
||||
'blank': '',
|
||||
}
|
||||
META_KEYS = ('ashen_steel_ingot', 'ashen_steel_mixture', 'ashen_steel_nugget', 'ashen_steel_rod',
|
||||
'metal_pipe', 'metal_sheet', 'small_metal_sheet', 'scrap_nugget',
|
||||
'diamond_nugget', 'netherite_nugget')
|
||||
FABRIC_KEYS = ('cloth', 'dirty_rags', 'dish_towel', 'fabric_patch', 'fiber_fabric', 'polyester',
|
||||
'rags', 'sterilized_rags', 'kevlar', 'leather_strip')
|
||||
THREAD_KEYS = ('thread', 'kevlar_thread', 'polyester_thread', 'copper_wire', 'insulated_copper_wire', 'wire')
|
||||
FASTENER_KEYS = ('nails', 'screws', 'box_of_nails', 'box_of_screws', 'box_of_paperclips', 'paperclip')
|
||||
SCRAP_KEYS = ('metal_scrap', 'electric_scrap', 'scrap_wood')
|
||||
PLASTIC_KEYS = ('plastic', 'plastic_bag', 'plastic_plate', 'cardboard')
|
||||
ADHESIVE_KEYS = ('glue', 'medical_adhesive', 'adhesive_tape', 'duct_tape')
|
||||
|
||||
def make_desc(name, zh):
|
||||
if name in SPECIAL:
|
||||
return SPECIAL[name]
|
||||
if name in META_KEYS:
|
||||
return '用于锻造与回收的金属材料。'
|
||||
if name in SCRAP_KEYS:
|
||||
return '可回收利用的材料。'
|
||||
if name in FABRIC_KEYS:
|
||||
return '用于缝制、修复与回收的织物材料。'
|
||||
if name in THREAD_KEYS:
|
||||
return '用于制作与缝合的线材。'
|
||||
if name in FASTENER_KEYS:
|
||||
return '用于组装的紧固件。'
|
||||
if name in PLASTIC_KEYS:
|
||||
return '可用于制作物品的塑料材料。'
|
||||
if name in ADHESIVE_KEYS:
|
||||
return '修复与组装的粘合材料。'
|
||||
if name in ('battery', 'camera', 'cellphone', 'classic_watch', 'falsh_lights'):
|
||||
return '可拆解的电子元件。'
|
||||
if name in ('sulfur', 'sulfur_dust', 'charcoal_dust', 'gunpowder_bottle'):
|
||||
return '可用于制作的化学材料。'
|
||||
if name in ('empty_can', 'dented_can', 'tin_can', 'empty_glass_bottle'):
|
||||
return '空容器,可回收利用。'
|
||||
if name in ('water_bottle', 'water_bottle2', 'alcohol', 'rubbing_alcohol', 'cleaning_liquid',
|
||||
'hair_gel', 'fermented_mash', 'gasoline_bucket'):
|
||||
return '装有液体的容器。'
|
||||
if name in ('lunch_bag',):
|
||||
return '存放食物的袋子。'
|
||||
return '合成与回收材料。'
|
||||
|
||||
# 1) 生成 beh / res json + 复制贴图
|
||||
beh_tpl = {'format_version': '1.10', 'minecraft:item': {
|
||||
'components': {'minecraft:max_stack_size': 64},
|
||||
'description': {'category': 'dn_sa', 'identifier': 'dn_sa:%s'}}}
|
||||
res_tpl = {'format_version': '1.10', 'minecraft:item': {
|
||||
'components': {'minecraft:icon': 'dn_sa:%s'},
|
||||
'description': {'identifier': 'dn_sa:%s'}}}
|
||||
|
||||
count = 0
|
||||
for name, zh in mats:
|
||||
beh_path = os.path.join(BEH, 'dn_sa_%s.json' % name)
|
||||
res_path = os.path.join(RES, 'dn_sa_%s.json' % name)
|
||||
with open(beh_path, 'w', encoding='utf-8') as f:
|
||||
json.dump(beh_tpl, f, ensure_ascii=False, indent=4)
|
||||
with open(res_path, 'w', encoding='utf-8') as f:
|
||||
json.dump(res_tpl, f, ensure_ascii=False, indent=4)
|
||||
shutil.copy2(os.path.join(SRC_TEX, name + '.png'), os.path.join(TEX, name + '.png'))
|
||||
count += 1
|
||||
print('已生成物品 json + 复制贴图:', count)
|
||||
|
||||
# 2) item_texture.json 追加
|
||||
with open(ITEM_TEX, encoding='utf-8') as f:
|
||||
it = json.load(f)
|
||||
added = 0
|
||||
for name, zh in mats:
|
||||
key = 'dn_sa:%s' % name
|
||||
if key not in it['texture_data']:
|
||||
it['texture_data'][key] = {'textures': 'textures/items/%s' % name}
|
||||
added += 1
|
||||
with open(ITEM_TEX, 'w', encoding='utf-8') as f:
|
||||
json.dump(it, f, ensure_ascii=False, indent=4)
|
||||
print('item_texture.json 新增条目:', added, '| 总数:', len(it['texture_data']))
|
||||
|
||||
# 3) zh_CN.lang 追加 name + desc
|
||||
lang = open(LANG, encoding='utf-8').read()
|
||||
lines_added = 0
|
||||
new_lines = []
|
||||
existing = set(lang.splitlines())
|
||||
for name, zh in mats:
|
||||
nk = 'item.dn_sa:%s.name=%s' % (name, zh)
|
||||
dk = 'item.dn_sa:%s.desc=%s' % (name, make_desc(name, zh))
|
||||
if nk not in existing:
|
||||
new_lines.append(nk); new_lines.append(dk); lines_added += 2
|
||||
if new_lines:
|
||||
with open(LANG, 'a', encoding='utf-8') as f:
|
||||
f.write('\n' + '\n'.join(new_lines) + '\n')
|
||||
print('zh_CN.lang 追加条目:', lines_added)
|
||||
Reference in new issue
Block a user