33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
#
|
|
# 草药使用效果(对齐 Java 版 sa_essentials 原设定)
|
|
# 大部分草药的效果已在各自物品 JSON 的 minecraft:food.effects 中直接配置;
|
|
# 本脚本只处理组件无法表达的「解毒」:使用后移除玩家身上的中毒效果。
|
|
# crushed_blue_herb / mixed_gb_herbs / mixed_ggb_herbs
|
|
# mixed_gyb_herbs / mixed_grb_herbs / mixed_rb_herbs
|
|
import mod.server.extraServerApi as serverApi
|
|
|
|
compFactory = serverApi.GetEngineCompFactory()
|
|
|
|
POISON_HERBS = (
|
|
"dn_sa:crushed_blue_herb",
|
|
"dn_sa:mixed_gb_herbs",
|
|
"dn_sa:mixed_ggb_herbs",
|
|
"dn_sa:mixed_gyb_herbs",
|
|
"dn_sa:mixed_grb_herbs",
|
|
"dn_sa:mixed_rb_herbs",
|
|
)
|
|
|
|
|
|
class HerbServer(serverApi.GetServerSystemCls()):
|
|
def __init__(self, namespace, name):
|
|
super(HerbServer, self).__init__(namespace, name)
|
|
self.ListenForEvent(serverApi.GetEngineNamespace(), serverApi.GetEngineSystemName(),
|
|
"PlayerEatFoodServerEvent", self, self.OnEatFood)
|
|
|
|
def OnEatFood(self, args):
|
|
playerId = args.get("playerId")
|
|
itemName = (args.get("itemDict") or {}).get("itemName")
|
|
if playerId and itemName in POISON_HERBS:
|
|
# 解毒:移除中毒状态
|
|
compFactory.CreateEffect(playerId).RemoveEffectFromEntity("poison") |