汤锅功能实现 6

This commit is contained in:
wenhe committed 2026-09-16 14:08:24 +08:00
1 parent c342dcc93d
commit 72172ba09c
8 files changed
+679 -568

No files matched your search

@@ -3,7 +3,7 @@
================================================================================
面食.甜食·右键转换引擎(服务端)
================================================================================
处理"面食.甜食"(xy_mianshi) 分类下的右键转换:
处理"面食.甜食"(xy_mianshi) 分类下的右键转换,
面粉·面团(和面/擀面/切分)、饺子、包子、馍、煎饼卷、竹筒饭、
面包堆叠/递减、面团胚料循环、甜点蛋糕(脱模/加料/切分)。
@@ -13,11 +13,11 @@
(多服务 fallback) 路由到本类 handleBlockUse / handleItemUseOn。
【本类怎么做】
handleBlockUse ← 入口:分发器转发右键方块事件
handleBlockUse ← 入口,分发器转发右键方块事件
├─ _handleKnead ← 揉面/和面 连点计数(空手)
├─ _handleAction ← 特殊动作(蒸笼取出/切小面团/切生面/蛋糕脱模)
└─ handleSwitch ← 通用转换(加料/擀面/卷制/堆叠/递减/切分)
handleItemUseOn ← 入口:生面饼右键烤炉烙制 / 面粉(加鸡蛋)右键木碗做面糊
handleItemUseOn ← 入口,生面饼右键烤炉烙制 / 面粉(加鸡蛋)右键木碗做面糊
(通用工具) getCarriedItem / consumeItem / giveItem / dropItem / replaceBlock /
clearBlock / checkCooldown
================================================================================
@@ -107,8 +107,8 @@ class MianshiService(BlueFoxServerSystem):
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)
self.timingTips[src] = "§e正在蒸制中…共需计时%d秒, 计时结束变成 %s" % (sec, tgt)
self.startTimerTips[src] = "§a开始蒸制: 还需%d秒, 计时结束变成 %s" % (sec, tgt)
self.timingTips[src] = "§e正在蒸制中: 还需%d秒, 计时结束变成 %s" % (sec, tgt)
# ---- 结果方块/物品 -> "下一步"可读提示(供转换/入笼提示追加) ----
# 例子: 饺子皮 -> "加入 猪肉馅、青菜碎"; 可颂面胚 -> "放在烤炉上等计时(60秒)结束变成 可颂"
@@ -195,9 +195,8 @@ class MianshiService(BlueFoxServerSystem):
if blockName in OVEN_FIX_BLOCKS and self._belowIs(dim, pos, OVEN):
FeatureDispatcher.startTimerFor(blockName, dim, pos, playerId)
if self.checkCooldown(key, 0.4):
tip = "§a开始烤制…共需计时60秒; 计时结束变成 " + \
self.timerTargetName.get(blockName, "成品")
comp.CreateMsg(playerId).NotifyOneMessage(playerId, tip)
comp.CreateMsg(playerId).NotifyOneMessage(
playerId, "§a已启动计时(共60秒)")
return True
# ---- 烤制成品取走: 空手右键成品(下方是烤炉) -> 成品掉落物, 烤炉不动 ----
@@ -295,7 +294,7 @@ class MianshiService(BlueFoxServerSystem):
tip = rule["tip"]
nxt = self._nextStepTip(rule.get("replace") or rule.get("above"))
if nxt:
tip += ";" + nxt
tip += "," + nxt
comp.CreateMsg(playerId).NotifyOneMessage(playerId, tip)
return True
@@ -313,7 +312,7 @@ class MianshiService(BlueFoxServerSystem):
started = FeatureDispatcher.startTimerFor(blockName, dim, pos, playerId)
if started:
comp.CreateMsg(playerId).NotifyOneMessage(
playerId, self.startTimerTips.get(blockName, "§a开始蒸制…"))
playerId, self.startTimerTips.get(blockName, "§a已启动计时"))
else:
comp.CreateMsg(playerId).NotifyOneMessage(
playerId, "§c蒸笼需要放在点燃的炉灶上才能开始蒸制")
@@ -412,11 +411,11 @@ class MianshiService(BlueFoxServerSystem):
tip = recipe["tip"]
nxt = self._nextStepTip(recipe.get("target") or recipe.get("dropItem"))
if nxt:
tip += ";" + nxt
tip += "," + nxt
comp.CreateMsg(playerId).NotifyOneMessage(playerId, tip)
# ============================================================================
# 五、工具方法:判断正下方是否指定方块(烤炉/点燃炉灶)
# 五、工具方法,判断正下方是否指定方块(烤炉/点燃炉灶)
# ============================================================================
def _belowIs(self, dim, pos, blockName):
@@ -431,7 +430,7 @@ class MianshiService(BlueFoxServerSystem):
return NAME_MAP.get(blockName, blockName)
def _nextStepTip(self, key):
"""按结果方块/物品生成"你可以…"的可读下一步提示; 无则返回空串
"""按结果方块/物品生成"你可以,"的可读下一步提示; 无则返回空串
例: 饺子皮 -> "你可以加入 猪肉馅、青菜碎"
可颂面胚 -> "你可以放在烤炉上等计时(60秒)结束变成 可颂"
"""
@@ -456,7 +455,7 @@ class MianshiService(BlueFoxServerSystem):
return "你可以" + " 或 ".join(parts)
# ============================================================================
# 六、工具方法:获取玩家主手物品
# 六、工具方法,获取玩家主手物品
# ============================================================================
def getCarriedItem(self, playerId):
@@ -465,7 +464,7 @@ class MianshiService(BlueFoxServerSystem):
serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
# ============================================================================
# 七、工具方法:给玩家物品
# 七、工具方法,给玩家物品
# ============================================================================
def giveItem(self, playerId, itemName, count=1, aux=0):
@@ -476,7 +475,7 @@ class MianshiService(BlueFoxServerSystem):
pass
# ============================================================================
# 八、工具方法:消耗物品
# 八、工具方法,消耗物品
# ============================================================================
def consumeItem(self, playerId, itemDict, amount=1):
@@ -497,7 +496,7 @@ class MianshiService(BlueFoxServerSystem):
"userData": itemDict.get("userData", {})})
# ============================================================================
# 九、工具方法:以掉落物形式生成物品
# 九、工具方法,以掉落物形式生成物品
# ============================================================================
def dropItem(self, dim, pos, itemName, count=1, aux=0):
@@ -508,7 +507,7 @@ class MianshiService(BlueFoxServerSystem):
pass
# ============================================================================
# 十、工具方法:替换方块 / 清空方块(保留 aux, 兼容定向变体)
# 十、工具方法,替换方块 / 清空方块(保留 aux, 兼容定向变体)
# ============================================================================
def replaceBlock(self, pos, dim, newBlockName, playerId=None):
@@ -529,7 +528,7 @@ class MianshiService(BlueFoxServerSystem):
oldBlockHandling=0, dimensionId=dim)
# ============================================================================
# 十一、工具方法:冷却检查
# 十一、工具方法,冷却检查
# ============================================================================
def checkCooldown(self, key, cd=0.4):