汤锅功能实现 3 计时 触发修改
This commit is contained in:
1 parent
25b023b703
commit
df71a62d7c
6 files changed
+174
-5
No files matched your search
+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油锅需要放在点燃的炉灶上才能开始计时")
|
||||
|
||||
# ============================================================================
|
||||
# 二、通用转换执行
|
||||
# ============================================================================
|
||||
|
||||
Reference in new issue
Block a user