汤锅功能实现 3 计时 触发修改

This commit is contained in:
wenhe committed 2026-09-16 10:46:53 +08:00
1 parent 25b023b703
commit df71a62d7c
6 files changed
+174 -5

No files matched your search

@@ -33,9 +33,12 @@ comp = serverApi.GetEngineCompFactory() # 组件工厂
from ....BlueFoxTools.SpecialFunciton.BlueFoxSystem import BlueFoxServerSystem
from ....BlueFoxTools.ToolsConfig import LevelId
# ---- 方块实体数据组件(检查蒸笼计时源是否已在计时中) ----
blockEntityDataComp = comp.CreateBlockEntityData(LevelId)
# ---- 只导入面食自己的数据库 ----
from ..MianshiData import (
CLEAVER, ROLLINGPIN, BOWL, PLATE, OVEN, STEAMER,
CLEAVER, ROLLINGPIN, BOWL, PLATE, OVEN, STEAMER, LIT_STOVE,
MEAT_ITEMS, FILLING_ITEMS, RICH_MEAT_ITEMS,
SWITCH_RULES, KNEAD_COUNTERS, ITEM_USE_ON_RULES, TIMER_RULES,
OVEN_FIX_BLOCKS, OVEN_RESULT_BLOCKS, NAME_MAP,
@@ -90,6 +93,21 @@ class MianshiService(BlueFoxServerSystem):
for b in OVEN_RESULT_BLOCKS:
self.featureBlocks.add(b)
# ---- 空手右键"蒸笼计时源"(蒸X_生): 放在点燃炉灶上 -> 开始计时 ----
# 蒸笼蒸制的计时源(下方必须点燃炉灶)才登记, 烤炉/发酵等走各自机制
self.timerSources = set()
self.startTimerTips = {}
for r in TIMER_RULES:
if LIT_STOVE not in (r.get("below") or []):
continue
src = r["source"]
self.timerSources.add(src)
self.featureBlocks.add(src)
if src not in self.startTimerTips:
sec = r.get("time", 60)
tgt = NAME_MAP.get(r["target"], r["target"])
self.startTimerTips[src] = "§a开始蒸制…等计时(%d秒)结束变成 %s" % (sec, tgt)
# ---- 结果方块/物品 -> "下一步"可读提示(供转换/入笼提示追加) ----
# 例子: 饺子皮 -> "加入 猪肉馅、青菜碎"; 可颂面胚 -> "放在烤炉上等计时(60秒)结束变成 可颂"
self.nextTips = {}
@@ -191,6 +209,13 @@ class MianshiService(BlueFoxServerSystem):
playerId, "§a取走" + self._nameOf(blockName))
return True
# ---- 空手右键"蒸笼计时源"(蒸X_生): 下方是点燃炉灶 -> 开始/继续计时 ----
if (not itemName or itemName == "minecraft:air") and blockName in self.timerSources:
if not self.checkCooldown(key, 0.4):
return True
self._handleStartTimer(blockName, playerId, pos, dim)
return True
# ---- 常规转换 ----
recipe = self.findRecipe(blockName, itemDict)
if not recipe:
@@ -272,6 +297,24 @@ class MianshiService(BlueFoxServerSystem):
comp.CreateMsg(playerId).NotifyOneMessage(playerId, tip)
return True
def _handleStartTimer(self, blockName, playerId, pos, dim):
"""空手右键蒸笼计时源(蒸X_生): 已在计时中 -> 提示;
否则转发计时服务开始(下方需点燃的炉灶 stove_2)"""
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蒸笼需要放在点燃的炉灶上才能开始蒸制")
# ============================================================================
# 二、规则匹配(精确 + 空手 fallback)
# ============================================================================