代码初始化
This commit is contained in:
1 parent
c2f5cd98ff
commit
e3efeb74ad
2439 files changed
+305661
-1
No files matched your search
@@ -0,0 +1,33 @@
|
||||
# -*- 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")
|
||||
Reference in new issue
Block a user