汤锅功能实现 3 计时 触发修改
This commit is contained in:
1 parent
25b023b703
commit
df71a62d7c
6 files changed
+174
-5
No files matched your search
+37
-1
@@ -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)
|
||||
# ============================================================================
|
||||
|
||||
+3
@@ -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:
|
||||
|
||||
+44
-1
@@ -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)
|
||||
# ============================================================================
|
||||
|
||||
+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 转发的"手持物品右键方块表面"入口(锅态汤面)。
|
||||
手持 蘑菇汤/蔬菜汤/蛋花汤 右键 熟面条表面 -> 汤面, 转换与取消放置同一事件完成"""
|
||||
|
||||
+42
-2
@@ -31,8 +31,11 @@ comp = serverApi.GetEngineCompFactory() # 组件工厂
|
||||
from ....BlueFoxTools.SpecialFunciton.BlueFoxSystem import BlueFoxServerSystem
|
||||
from ....BlueFoxTools.ToolsConfig import LevelId
|
||||
|
||||
# ---- 方块实体数据组件(检查是否已在计时中) ----
|
||||
blockEntityDataComp = comp.CreateBlockEntityData(LevelId)
|
||||
|
||||
# ---- 只导入油锅自己的数据库 ----
|
||||
from ..YouguoData import SWITCH_RULES, OILPOT_1
|
||||
from ..YouguoData import SWITCH_RULES, OILPOT_1, TIMER_RULES
|
||||
|
||||
# ---- 统一分发器 ----
|
||||
from ...service.FeatureDispatcher import FeatureDispatcher
|
||||
@@ -54,6 +57,17 @@ class YouguoService(BlueFoxServerSystem):
|
||||
self.recipes[(r["block"], r.get("item"))] = r
|
||||
self.featureBlocks.add(r["block"])
|
||||
|
||||
# ---- 空手右键"炸物计时源方块"(炸物生/半熟): 放在点燃炉灶上 -> 开始计时 ----
|
||||
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)
|
||||
self.startTimerTips[src] = "§a开始炸制…等计时(%d秒)结束变成 下一形态" % sec
|
||||
|
||||
# ---- 右键冷却表 ----
|
||||
self.cooldown = {}
|
||||
|
||||
@@ -82,14 +96,40 @@ class YouguoService(BlueFoxServerSystem):
|
||||
key = (dim, x, y, z)
|
||||
|
||||
itemDict = self.getCarriedItem(playerId)
|
||||
recipe = self.recipes.get((blockName, itemDict.get("newItemName") if itemDict else None))
|
||||
itemName = itemDict.get("newItemName") if itemDict else None
|
||||
if itemName == "minecraft:air":
|
||||
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油锅需要放在点燃的炉灶上才能开始计时")
|
||||
|
||||
# ============================================================================
|
||||
# 二、通用转换执行
|
||||
# ============================================================================
|
||||
|
||||
@@ -88,6 +88,13 @@
|
||||
- 事件由 FeatureDispatcher 统一监听路由 (blockOwner/itemUseOnOwner/timerOwner) [已实现]
|
||||
- 右键服务通过 FeatureDispatcher.startTimerFor 把计时启动转发给计时服务 [已实现]
|
||||
- 计时用绝对时间戳写入方块实体数据, 支持退出/重启后继续计时 [已实现]
|
||||
- 计时源方块"空手右键开始计时"(2026-09-15): 所有下方必须是点燃炉灶(stove_2)的
|
||||
计时源方块(汤锅汤羹/生米锅、油锅炸物生/半熟、丸子机加料后/半熟、蒸笼蒸X_生),
|
||||
单独放置或转换后未触发计时时, 空手右键该方块即可开始/继续计时;
|
||||
下方是点燃炉灶才真正开始(否则提示"需要放在点燃的炉灶上"), 已在计时中再空手右键
|
||||
提示"已经在计时中"; 实现于 汤锅/油锅/丸子机(ChujuService)/面食蒸笼(MianshiService)
|
||||
的 handleBlockUse + 各自 _handleStartTimer, 经 FeatureDispatcher.startTimerFor 转发,
|
||||
计时服务 startTimer 内做下方判定(丸子机 ChujuTimerService 已补下方检查) [已实现]
|
||||
- 原版放置(手持原版生鸡肉/鲑鱼/鳕鱼右键方块表面放置对应方块)已拆到独立目录
|
||||
xiangyemod/yuanbanfangzhi (YuanbanData/YuanbanService), 从烧烤/死亡生物中剔除 [已重构]
|
||||
- 原版食物成品盘转换(乡野食物·原版食物): 手持原版食物右键 空盘子(rtdd:plate_0) →
|
||||
|
||||
Reference in new issue
Block a user