This commit is contained in:
wenhe committed 2026-09-23 14:27:13 +08:00
1 parent 9eb9edbb8a
commit b768ff1555
10 files changed
+618 -15

No files matched your search

@@ -257,6 +257,35 @@ class TangguoService(BlueFoxServerSystem):
# 二、通用转换执行
# ============================================================================
def handleTakeoutRequest(self, playerId, blockName, itemName, dim, pos):
"""客户端显式触发的盛出请求(消闪方案)。
客户端已把 (碗/盘, 成品汤方块) 的放置预览拦掉(见 ClientFeatureDispatcher),
本方法在服务端补齐盛出逻辑, 与右键 take_out 等效:
- 校验落点仍是该成品方块(防客户端事件与服务端 ServerBlockUseEvent 双份)
- 用 (block, item) 精确定位盛出规则并执行 switch
"""
# 守卫1: 防空手/非碗盘(客户端已过滤, 这里再兜底)
if not itemName or itemName in ("minecraft:air",):
return
try:
b = comp.CreateBlockInfo(LevelId).GetBlockNew(pos, dim)
cur = b.get("name") if b else None
except Exception:
cur = None
# 守卫2: 落点方块已不是该成品(可能已被旧路径/上一次盛出处理掉) -> 跳过, 防重复
if cur != blockName:
print "[TakeoutRequest-SKIP-ALREADY]", "want:", blockName, "cur:", cur, "pos:", pos
return
recipe = self.recipes.get((blockName, itemName))
if not recipe or recipe.get("action") != "take_out":
return
# 守卫3: 冷却, 防连点双发
if not self.checkCooldown((dim, pos[0], pos[1], pos[2]), 0.4):
return
itemDict = self.getCarriedItem(playerId)
self.handleSwitch(recipe, playerId, pos, dim, itemDict)
print "[TakeoutRequest-DONE]", "player:", playerId, "item:", itemName, "block:", blockName
def handleSwitch(self, recipe, playerId, pos, dim, itemDict):
# 消耗物品(数量不足则拦截, 不转换)
consume = recipe.get("consume", 0)