diff --git a/behavior_pack_v8jz0zSR/Script_NeteaseModousIY5aSF/ceshi/service/CookingService.py b/behavior_pack_v8jz0zSR/Script_NeteaseModousIY5aSF/ceshi/service/CookingService.py index 31b93c1..240add8 100644 --- a/behavior_pack_v8jz0zSR/Script_NeteaseModousIY5aSF/ceshi/service/CookingService.py +++ b/behavior_pack_v8jz0zSR/Script_NeteaseModousIY5aSF/ceshi/service/CookingService.py @@ -369,6 +369,10 @@ class CookingService(BlueFoxServerSystem): if recipe.get("target"): self.replaceBlock(pos, dim, recipe["target"], playerId) + # 如果配方指定了给物品(如烧烤架浇水给桶) + if recipe.get("giveItem"): + self.giveItem(playerId, recipe["giveItem"]) + return # ---- 逆向操作:从方块里取东西(空手右键或取回物品) ---- @@ -399,6 +403,10 @@ class CookingService(BlueFoxServerSystem): else: self.switchRecord[key] = record + # 如果配方直接指定了给什么物品(水槽、盘子架取回、挂肉钩退回等) + if recipe.get("giveItem"): + self.giveItem(playerId, recipe["giveItem"]) + # 替换方块 if recipe.get("target"): self.replaceBlock(pos, dim, recipe["target"], playerId) @@ -613,7 +621,7 @@ class CookingService(BlueFoxServerSystem): # 工具方法:替换方块 # ============================================================================ - def replaceBlock(self, pos, dim, newBlockName, playerId): + def replaceBlock(self, pos, dim, newBlockName, playerId, aux=None): """ 把指定位置的方块替换成新方块。 @@ -622,15 +630,23 @@ class CookingService(BlueFoxServerSystem): dim: 维度ID newBlockName: 新方块的完整ID,如 "rtdd:oilpan" playerId: 玩家ID(用于创建组件) + aux: 方块附加值(朝向)。None=自动继承旧方块的朝向,数字=强制指定 对照 BlockBlock.py 的标准写法: - 使用命名参数 - oldBlockHandling=0 表示直接替换(不保留旧方块数据) - - aux=0 表示默认附加值 + - aux 默认继承旧方块朝向,这样替换后不会转方向 """ + # 如果没指定 aux,自动读取旧方块的朝向并继承 + if aux is None: + try: + oldBlock = comp.CreateBlockInfo(playerId).GetBlockNew(pos, dim) + aux = oldBlock.get("aux", 0) + except: + aux = 0 comp.CreateBlockInfo(playerId).SetBlockNew( pos, - blockDict={"name": newBlockName, "aux": 0}, + blockDict={"name": newBlockName, "aux": aux}, oldBlockHandling=0, dimensionId=dim)