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

@@ -125,20 +125,20 @@ SWITCH_RULES = [
{"block": "rtdd:farineblock_1", "item": WATER_BUCKET,
"target": "rtdd:farineblock_2", "consume": 1, "give": EMPTY_BUCKET,
"tip": "§a面粉加水, 水桶变空桶"},
{"block": "rtdd:rawdough_0", "item": None, "target": "rtdd:rawdough_1", "tip": "§a和面中…"},
{"block": "rtdd:rawdough_1", "item": None, "target": "rtdd:rawdough_2", "tip": "§a和面中…"},
{"block": "rtdd:rawdough_2", "item": None, "target": "rtdd:rawdough_3", "tip": "§a和面中…"},
{"block": "rtdd:rawdough_0", "item": None, "target": "rtdd:rawdough_1", "tip": "§a和面中,"},
{"block": "rtdd:rawdough_1", "item": None, "target": "rtdd:rawdough_2", "tip": "§a和面中,"},
{"block": "rtdd:rawdough_2", "item": None, "target": "rtdd:rawdough_3", "tip": "§a和面中,"},
{"block": "rtdd:rawdough_3", "item": None, "target": "rtdd:rawdough_4",
"startTimer": "rtdd:rawdough_4", "tip": "§a和面完成, 开始发酵"},
{"block": "rtdd:rawdough_4", "item": CLEAVER, "action": "chop_smalldough",
"tip": "§a切出了8个小面团"},
{"block": "rtdd:dough_0", "item": ROLLINGPIN, "target": "rtdd:dough_1",
"consume": 1, "tip": "§a开始擀面(消耗1根擀面杖)"},
{"block": "rtdd:dough_1", "item": None, "target": "rtdd:dought_2", "tip": "§a擀面中…"},
{"block": "rtdd:dought_2", "item": None, "target": "rtdd:dought_3", "tip": "§a擀面中…"},
{"block": "rtdd:dought_3", "item": None, "target": "rtdd:dought_4", "tip": "§a擀面中…"},
{"block": "rtdd:dought_4", "item": None, "target": "rtdd:dought_5", "tip": "§a擀面中…"},
{"block": "rtdd:dought_5", "item": None, "target": "rtdd:dought_6", "tip": "§a擀面中…"},
{"block": "rtdd:dough_1", "item": None, "target": "rtdd:dought_2", "tip": "§a擀面中,"},
{"block": "rtdd:dought_2", "item": None, "target": "rtdd:dought_3", "tip": "§a擀面中,"},
{"block": "rtdd:dought_3", "item": None, "target": "rtdd:dought_4", "tip": "§a擀面中,"},
{"block": "rtdd:dought_4", "item": None, "target": "rtdd:dought_5", "tip": "§a擀面中,"},
{"block": "rtdd:dought_5", "item": None, "target": "rtdd:dought_6", "tip": "§a擀面中,"},
{"block": "rtdd:dought_6", "item": None, "target": "rtdd:dought_7",
"give": ROLLINGPIN, "tip": "§a擀好了, 擀面杖返还"},
{"block": "rtdd:dought_7", "item": CLEAVER, "target": "rtdd:dought_8", "tip": "§a面饼切开"},
@@ -147,8 +147,8 @@ SWITCH_RULES = [
"tip": "§a切出了生面"},
{"block": "rtdd:smalldough_0", "item": ROLLINGPIN, "target": "rtdd:smalldough_1",
"consume": 1, "tip": "§a开始擀小面团(消耗1根擀面杖)"},
{"block": "rtdd:smalldough_1", "item": None, "target": "rtdd:smalldough_2", "tip": "§a擀小面团中…"},
{"block": "rtdd:smalldough_2", "item": None, "target": "rtdd:smalldough_3", "tip": "§a擀小面团中…"},
{"block": "rtdd:smalldough_1", "item": None, "target": "rtdd:smalldough_2", "tip": "§a擀小面团中,"},
{"block": "rtdd:smalldough_2", "item": None, "target": "rtdd:smalldough_3", "tip": "§a擀小面团中,"},
{"block": "rtdd:smalldough_3", "item": None, "action": "drop_dumpling_skin",
"dropItem": "rtdd:dumplings_0", "give": ROLLINGPIN,
"tip": "§a压成饺子皮, 擀面杖返还"},
@@ -174,7 +174,7 @@ SWITCH_RULES = [
"tip": "§a包子皮加了肉馅"},
{"block": "rtdd:baozipi", "item": BEEF_FILLING, "target": "rtdd:roubao_1",
"tip": "§a包子皮加了肉馅"},
{"block": "rtdd:roubao_1", "item": None, "target": "rtdd:roubao_2", "tip": "§a塑形中…"},
{"block": "rtdd:roubao_1", "item": None, "target": "rtdd:roubao_2", "tip": "§a塑形中,"},
{"block": "rtdd:roubao_2", "item": None, "action": "drop_result",
"dropItem": "rtdd:roubaozi_3", "tip": "§a塑形成生肉包子"},
{"block": "rtdd:baozilong_2", "item": None, "action": "take_steamer",
@@ -208,9 +208,9 @@ SWITCH_RULES = [
{"block": "rtdd:cookeddought_2", "item": POTATO, "target": "rtdd:cookeddought_3",
"consume": 1, "tip": "§a加入土豆"},
{"block": "rtdd:cookeddought_3", "item": None, "target": "rtdd:cookeddought_4",
"tip": "§a卷制中…"},
"tip": "§a卷制中,"},
{"block": "rtdd:cookeddought_4", "item": None, "target": "rtdd:cookeddought_5",
"tip": "§a卷制中…"},
"tip": "§a卷制中,"},
{"block": "rtdd:cookeddought_5", "item": None, "target": "rtdd:cookeddought_6",
"tip": "§a煎饼卷牛肉完成"},
{"block": "rtdd:cookeddought_1", "item": COOKED_COD, "target": "rtdd:cookedcoddought_2",
@@ -218,9 +218,9 @@ SWITCH_RULES = [
{"block": "rtdd:cookedcoddought_2", "item": POTATO, "target": "rtdd:cookedcoddought_3",
"consume": 1, "tip": "§a加入土豆"},
{"block": "rtdd:cookedcoddought_3", "item": None, "target": "rtdd:cookedcoddought_4",
"tip": "§a卷制中…"},
"tip": "§a卷制中,"},
{"block": "rtdd:cookedcoddought_4", "item": None, "target": "rtdd:cookedcoddought_5",
"tip": "§a卷制中…"},
"tip": "§a卷制中,"},
{"block": "rtdd:cookedcoddought_5", "item": None, "target": "rtdd:cookedcoddought_6",
"tip": "§a煎饼卷鳕鱼完成"},
@@ -310,9 +310,9 @@ SWITCH_RULES = [
# ============================================================================
KNEAD_COUNTERS = {
"rtdd:farineblock_2": {"times": 2, "target": "rtdd:farineblock_3",
"tip": "§a揉面中…(%d/2)", "doneTip": "§a揉好了, 变成面粉块"},
"tip": "§a揉面中,(%d/2)", "doneTip": "§a揉好了, 变成面粉块"},
"rtdd:farineblock_3": {"times": 3, "target": "rtdd:rawdough_0",
"tip": "§a和面中…(%d/3)", "doneTip": "§a和好面了, 变成生面团"},
"tip": "§a和面中,(%d/3)", "doneTip": "§a和好面了, 变成生面团"},
}
# ============================================================================
@@ -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):