汤锅功能实现 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

@@ -43,7 +43,7 @@ gameComp = comp.CreateGame(LevelId)
# ---- 只导入厨具自己的数据库 ----
from ..ChujuData import (
STOVE_RULES, MEATBALLMAKER_RULES,
STOVE_RULES, MEATBALLMAKER_RULES, MEATBALL_TIMERS,
MEAT_ITEMS, MILK_ITEM, BUCKET_ITEM, EGG_ITEM,
BOWL_ITEM, PLATE_ITEM, CREAM_ITEM, EGG_CUSTARD_ITEM, BEATER_BLOCKS,
SOYBEAN_ITEM, SOYBEAN_COUNT, STONEMILL_GRIND_COUNT,
@@ -79,6 +79,17 @@ class ChujuService(BlueFoxServerSystem):
# ---- 搅拌器方块集合(专用 handler) ----
self.beaterBlockSet = set(BEATER_BLOCKS)
# ---- 空手右键"丸子机计时源"(meatballmaker_3/4): 放在点燃炉灶上 -> 开始计时 ----
self.timerSources = set()
self.startTimerTips = {}
for r in MEATBALL_TIMERS:
src = r["source"]
self.timerSources.add(src)
self.featureBlocks.add(src)
if src not in self.startTimerTips:
sec = r.get("time", 60)
self.startTimerTips[src] = "§a开始烹制…等计时(%d秒)结束变成 下一形态" % sec
# ---- 右键冷却表 ----
self.cooldown = {}
@@ -121,6 +132,13 @@ class ChujuService(BlueFoxServerSystem):
if blockName == "rtdd:stonemill":
return self._handleStonemill(playerId, pos, dim, itemDict, itemName, key)
# ---- 空手右键"丸子机计时源"(meatballmaker_3/4): 放在点燃炉灶上 -> 开始计时 ----
if itemName in (None, "minecraft:air") and blockName in self.timerSources:
if not self.checkCooldown(key, 0.4):
return True
self._handleStartTimer(blockName, playerId, pos, dim)
return True
# ---- 炉灶/丸子机/蒸笼: 通用 switch 规则 ----
recipe = self.findRecipe(blockName, itemDict)
if not recipe:
@@ -135,6 +153,24 @@ class ChujuService(BlueFoxServerSystem):
self.handleSwitch(recipe, playerId, pos, dim, itemDict, key)
return True
def _handleStartTimer(self, blockName, playerId, pos, dim):
"""空手右键丸子机计时源(meatballmaker_3/4): 已在计时中 -> 提示;
否则转发计时服务开始(下方需点燃的炉灶 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丸子机需要放在点燃的炉灶上才能开始烹制")
# ============================================================================
# 二、通用规则匹配(精确 + *any)
# ============================================================================
@@ -88,6 +88,9 @@ class ChujuTimerService(BlueFoxServerSystem):
recipe = self.meatballTimers.get(blockName)
if not recipe:
return False
# 下方必须是点燃的炉灶(stove_2)才真正开始计时, 否则返回 False
if not self.checkBelow(recipe, dim, pos):
return False
try:
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
if data and data["rtdd_tid"] == blockName: