配方 替换方块ceshi5

This commit is contained in:
wenhe committed 2026-07-21 16:04:04 +08:00
1 parent 9ef1fedc2e
commit fcb08e0119
5 files changed
+23 -84

No files matched your search

@@ -88,10 +88,6 @@ class CookingService(BlueFoxServerSystem):
# ==================== 主入口:玩家右键方块 ====================
def OnBlockUse(self, args):
"""
玩家右键方块时触发。
流程:查配方 → 验条件 → 处理翻炒 → 消耗物品 → 替换方块 → 给物品 → 播声音
"""
blockName = args.get("blockName")
playerId = args.get("playerId")
x, y, z = args.get("x"), args.get("y"), args.get("z")
@@ -126,26 +122,20 @@ class CookingService(BlueFoxServerSystem):
# ==================== 配方执行(普通替换) ====================
def executeRecipe(self, recipe, playerId, pos, dim, itemDict):
# 1. 检查附加条件
if not self.checkConditions(recipe, playerId, pos, dim, itemDict):
return
# 2. 消耗物品
if recipe.get("consume", 1) > 0:
self.consumeItem(playerId, itemDict, recipe.get("consume", 1))
if recipe.get("needOil"):
self.removeOil(itemDict, playerId)
# 3. 替换方块
if recipe.get("target"):
self.replaceBlock(pos, dim, recipe["target"], playerId)
# 4. 给物品
if recipe.get("giveItem"):
self.giveItem(playerId, recipe["giveItem"])
# 5. 播放声音(需要配合 BlueFox 框架的客户端 PlaySound 事件,此处暂不实现)
# ==================== 翻炒处理 ====================
def handleStir(self, key, recipe, playerId, pos, dim, itemDict):