Files
xczjhk/统计/_sa_hanhua_out/_tmp/add_drinks.py
T
2026-10-09 18:08:05 +08:00

30 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
"""给可饮用液体材料添加饮用功能:beh food 组件 + res drink 动画"""
import os, json
BASE = r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a'
DRINKS = ['alcohol', 'rubbing_alcohol', 'cleaning_liquid', 'hair_gel', 'fermented_mash']
for m in DRINKS:
# beh json
p = os.path.join(BASE, 'behavior_pack_kcH4M5u0/netease_items_beh/dn_sa_%s.json' % m)
d = json.load(open(p, encoding='utf-8'))
c = d['minecraft:item']['components']
c['minecraft:use_duration'] = 32
c['minecraft:food'] = {
'nutrition': 2,
'saturation_modifier': 'low',
'can_always_eat': True
}
json.dump(d, open(p, 'w', encoding='utf-8'), ensure_ascii=False, indent=4)
# res json
rp = os.path.join(BASE, 'resource_pack_t7eJjrxY/netease_items_res/dn_sa_%s.json' % m)
r = json.load(open(rp, encoding='utf-8'))
r['minecraft:item']['components']['minecraft:use_animation'] = 'drink'
json.dump(r, open(rp, 'w', encoding='utf-8'), ensure_ascii=False, indent=4)
print('已添加饮用功能:', m)
# 验证
p = os.path.join(BASE, 'behavior_pack_kcH4M5u0/netease_items_beh/dn_sa_alcohol.json')
print(json.dumps(json.load(open(p, encoding='utf-8'))['minecraft:item']['components'], ensure_ascii=False, indent=1))