代码测试 2026年7月30日 3 加取消动作 还有bug
This commit is contained in:
1 parent
6bd2af9a79
commit
9c6bb1aacc
1 file changed
+43
-2
@@ -225,6 +225,9 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
# 没找到匹配的配方 → 不是做菜操作,不拦截,让游戏正常处理
|
# 没找到匹配的配方 → 不是做菜操作,不拦截,让游戏正常处理
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# 找到配方后,取消默认行为(如喝药水、吃食物等),由本 Mod 全权接管
|
||||||
|
args['cancel'] = True
|
||||||
|
|
||||||
# ---- 第四步:判断是不是工具切换类型 ----
|
# ---- 第四步:判断是不是工具切换类型 ----
|
||||||
recipeType = recipe.get("type", "cook")
|
recipeType = recipe.get("type", "cook")
|
||||||
# type="switch" 或 "timer" → 工具方块切换(箭桶、挂肉钩、水槽等)
|
# type="switch" 或 "timer" → 工具方块切换(箭桶、挂肉钩、水槽等)
|
||||||
@@ -351,7 +354,20 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
# 检查是否满了
|
# 检查是否满了
|
||||||
maxCount = recipe.get("maxCount", 999)
|
maxCount = recipe.get("maxCount", 999)
|
||||||
if record["count"] >= maxCount:
|
if record["count"] >= maxCount:
|
||||||
return # 满了,不能再放
|
# 满了,自动转向取回操作
|
||||||
|
takeRecipe = self.allRecipes.get((blockName, None))
|
||||||
|
if takeRecipe and record["count"] > 0:
|
||||||
|
self.giveItem(playerId, record["itemName"])
|
||||||
|
record["count"] -= 1
|
||||||
|
if takeRecipe.get("giveItem"):
|
||||||
|
self.giveItem(playerId, takeRecipe["giveItem"])
|
||||||
|
if takeRecipe.get("target"):
|
||||||
|
self.replaceBlock(pos, dim, takeRecipe["target"], playerId)
|
||||||
|
if record["count"] <= 0:
|
||||||
|
self.clearSwitchRecord(key, playerId, pos, dim)
|
||||||
|
else:
|
||||||
|
self._saveRecord(key, playerId, pos, dim, record)
|
||||||
|
return
|
||||||
# 记录物品+1
|
# 记录物品+1
|
||||||
record["count"] += 1
|
record["count"] += 1
|
||||||
needSave = True
|
needSave = True
|
||||||
@@ -362,7 +378,32 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
record = {"stack": []}
|
record = {"stack": []}
|
||||||
maxCount = recipe.get("maxCount", 999)
|
maxCount = recipe.get("maxCount", 999)
|
||||||
if len(record["stack"]) >= maxCount:
|
if len(record["stack"]) >= maxCount:
|
||||||
return # 满了
|
# 满了,自动转向取回操作
|
||||||
|
takeRecipe = self.allRecipes.get((blockName, None))
|
||||||
|
if takeRecipe:
|
||||||
|
needSave = False
|
||||||
|
needClear = False
|
||||||
|
if record["stack"]:
|
||||||
|
topItem = record["stack"].pop()
|
||||||
|
comp.CreateItem(playerId).SpawnItemToPlayerInv(
|
||||||
|
{"itemName": topItem["itemName"],
|
||||||
|
"count": topItem["count"],
|
||||||
|
"auxValue": topItem["auxValue"],
|
||||||
|
"userData": topItem.get("userData", {})},
|
||||||
|
playerId)
|
||||||
|
if not record["stack"]:
|
||||||
|
needClear = True
|
||||||
|
else:
|
||||||
|
needSave = True
|
||||||
|
if takeRecipe.get("giveItem"):
|
||||||
|
self.giveItem(playerId, takeRecipe["giveItem"])
|
||||||
|
if takeRecipe.get("target"):
|
||||||
|
self.replaceBlock(pos, dim, takeRecipe["target"], playerId)
|
||||||
|
if needClear:
|
||||||
|
self.clearSwitchRecord(key, playerId, pos, dim)
|
||||||
|
elif needSave:
|
||||||
|
self._saveRecord(key, playerId, pos, dim, record)
|
||||||
|
return
|
||||||
# 把物品信息压入堆栈
|
# 把物品信息压入堆栈
|
||||||
record["stack"].append({
|
record["stack"].append({
|
||||||
"itemName": itemDict["newItemName"],
|
"itemName": itemDict["newItemName"],
|
||||||
|
|||||||
Reference in new issue
Block a user