汤锅功能实现 3 计时 触发修改
This commit is contained in:
1 parent
25b023b703
commit
df71a62d7c
6 files changed
+174
-5
No files matched your search
+41
-1
@@ -32,8 +32,11 @@ comp = serverApi.GetEngineCompFactory() # 组件工厂
|
||||
from ....BlueFoxTools.SpecialFunciton.BlueFoxSystem import BlueFoxServerSystem
|
||||
from ....BlueFoxTools.ToolsConfig import LevelId
|
||||
|
||||
# ---- 方块实体数据组件(检查是否已在计时中) ----
|
||||
blockEntityDataComp = comp.CreateBlockEntityData(LevelId)
|
||||
|
||||
# ---- 只导入汤锅自己的数据库 ----
|
||||
from ..TangguoData import SWITCH_RULES, ITEM_USE_ON_RULES
|
||||
from ..TangguoData import SWITCH_RULES, ITEM_USE_ON_RULES, TIMER_RULES
|
||||
|
||||
# ---- 统一分发器 ----
|
||||
from ...service.FeatureDispatcher import FeatureDispatcher
|
||||
@@ -60,6 +63,20 @@ class TangguoService(BlueFoxServerSystem):
|
||||
for r in ITEM_USE_ON_RULES:
|
||||
self.itemUseOnRecipes[(r["item"], r["surface"])] = r
|
||||
|
||||
# ---- 空手右键"计时源方块"(生汤羹/生米锅等): 放在点燃炉灶上 -> 开始计时 ----
|
||||
self.timerSources = set()
|
||||
self.startTimerTips = {}
|
||||
for r in TIMER_RULES:
|
||||
src = r["source"]
|
||||
self.timerSources.add(src)
|
||||
self.featureBlocks.add(src) # 登记右键路由, 空手右键才分发到这里
|
||||
if src not in self.startTimerTips:
|
||||
sec = r.get("time", 60)
|
||||
if r.get("randomTargets"):
|
||||
self.startTimerTips[src] = "§a开始煮饭…等计时(%d秒)结束变成 熟米饭(形态随机)" % sec
|
||||
else:
|
||||
self.startTimerTips[src] = "§a开始熬制…等计时(%d秒)结束变成 下一形态" % sec
|
||||
|
||||
# ---- 右键冷却表 ----
|
||||
self.cooldown = {}
|
||||
|
||||
@@ -94,12 +111,35 @@ class TangguoService(BlueFoxServerSystem):
|
||||
itemName = None
|
||||
recipe = self.recipes.get((blockName, itemName))
|
||||
if not recipe:
|
||||
# 空手右键"计时源方块"(生汤羹/生米锅等): 下方是点燃炉灶 -> 开始计时
|
||||
if itemName is None and blockName in self.timerSources:
|
||||
if not self.checkCooldown(key, 0.4):
|
||||
return True
|
||||
self._handleStartTimer(blockName, playerId, pos, dim)
|
||||
return True
|
||||
return False
|
||||
if not self.checkCooldown(key, 0.4):
|
||||
return True
|
||||
self.handleSwitch(recipe, playerId, pos, dim, itemDict)
|
||||
return True
|
||||
|
||||
def _handleStartTimer(self, blockName, playerId, pos, dim):
|
||||
"""空手右键生汤羹等: 已在计时中 -> 提示; 否则转发计时服务开始(下方需点燃炉灶)"""
|
||||
try:
|
||||
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if data and data["rtdd_tid"] == blockName:
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(playerId, "§e已经在计时中")
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
started = FeatureDispatcher.startTimerFor(blockName, dim, pos, playerId)
|
||||
if started:
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(
|
||||
playerId, self.startTimerTips.get(blockName, "§a开始计时…"))
|
||||
else:
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(
|
||||
playerId, "§c汤锅需要放在点燃的炉灶上才能开始计时")
|
||||
|
||||
def handleItemUseOn(self, args):
|
||||
"""由 FeatureDispatcher 转发的"手持物品右键方块表面"入口(锅态汤面)。
|
||||
手持 蘑菇汤/蔬菜汤/蛋花汤 右键 熟面条表面 -> 汤面, 转换与取消放置同一事件完成"""
|
||||
|
||||
Reference in new issue
Block a user