配方 替换方块ceshi5
This commit is contained in:
1 parent
9ef1fedc2e
commit
fcb08e0119
4 files changed
+20
-81
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
from mod.common.mod import Mod
|
||||||
from OtherTools import *
|
from OtherTools import *
|
||||||
from SpecialFunciton.BlueFoxSystem import *
|
from SpecialFunciton.BlueFoxSystem import *
|
||||||
from SystemTools import *
|
from SystemTools import *
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ class PlayerBehaviorTree(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
from .ModConfig import MOD_NAME, MOD_VERSION
|
||||||
|
|
||||||
LevelId = serverApi.GetLevelId() or clientApi.GetLevelId()
|
LevelId = serverApi.GetLevelId() or clientApi.GetLevelId()
|
||||||
Platform = serverApi.GetPlatform() or clientApi.GetPlatform()
|
Platform = serverApi.GetPlatform() or clientApi.GetPlatform()
|
||||||
# Platform = 1 # 测试用
|
# Platform = 1 # 测试用
|
||||||
|
|||||||
@@ -1,85 +1,31 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
配方数据文件 - 所有"右键方块→消耗物品→替换方块"的配方都在这里
|
配方数据文件 - 所有烹饪配方都在这里
|
||||||
===============================================================
|
===================================
|
||||||
每加一道新菜,只需要在这里加一条配方,不用写任何Python代码。
|
每加一道菜,在这里加一条配方就行,不用写代码。
|
||||||
|
|
||||||
配方字典字段说明([] = 可选,{} = 特殊类型):
|
字段说明:
|
||||||
{
|
source = 被右键的方块ID(必填)
|
||||||
"source": str, # 被右键的方块ID(必填)
|
item = 手里必须拿的物品,None=空手也行
|
||||||
"item": str|None, # 玩家手里必须拿的物品,None=空手也行
|
target = 替换成什么方块
|
||||||
[below]: str, # 方块下面必须是什么
|
consume = 消耗几个物品(默认1,0=不消耗)
|
||||||
[needOil]: bool, # 物品必须有"油标签"
|
giveItem = 额外给玩家什么物品
|
||||||
[target]: str|None, # 替换成什么方块,None=不替换
|
below = 方块下面必须垫什么(可选)
|
||||||
[consume]: int, # 消耗物品数量,0=不消耗(默认1)
|
|
||||||
[giveItem]: str, # 额外给玩家什么物品
|
|
||||||
[sound]: str, # 播放什么声音
|
|
||||||
[soundPitch]: float, # 声音频率(默认1.0)
|
|
||||||
[stirCount]: int, # 需要翻炒几次才变身
|
|
||||||
[stirCd]: float, # 翻炒冷却时间(秒)
|
|
||||||
[onDone]: str, # 完成动作:"finish"=标记熟了不替换
|
|
||||||
[doneMsg]: str, # 完成后的提示消息
|
|
||||||
[failMsg]: str, # 冷却中/失败时的提示
|
|
||||||
[dropIfDone]: list, # 熟了后拆掉掉落什么
|
|
||||||
[dropIfNot]: list, # 没熟拆掉掉落什么
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# 炒菜示例:胡萝卜牛肉(完整一条链)
|
|
||||||
# ============================================================
|
|
||||||
# 流程:空锅 → 加油 → 放牛肉 → 翻炒 → 熟了 → 拆掉拿熟牛肉
|
|
||||||
RECIPES = [
|
RECIPES = [
|
||||||
|
|
||||||
# ===== 步骤1:空炒锅 + 有油的物品 → 带油煎锅 =====
|
# ================================================================
|
||||||
|
# 测试配方(最简单的一条,验证引擎能不能跑通)
|
||||||
|
# ================================================================
|
||||||
|
# 玩法:放一个 rtdd:wok(炒锅),手里拿生牛肉右键它
|
||||||
|
# 锅会变成钻石块,牛肉消失,背包里多一块熟牛肉
|
||||||
{
|
{
|
||||||
"source": "rtdd:wok",
|
"source": "rtdd:wok",
|
||||||
"item": None,
|
|
||||||
"below": "minecraft:campfire",
|
|
||||||
"needOil": True,
|
|
||||||
"target": "rtdd:cookinggarlic",
|
|
||||||
"consume": 0,
|
|
||||||
"sound": "random.fizz",
|
|
||||||
"soundPitch": 2.4,
|
|
||||||
},
|
|
||||||
|
|
||||||
# ===== 步骤2:带油煎锅 + 生牛肉 → 胡萝卜牛肉锅 =====
|
|
||||||
{
|
|
||||||
"source": "rtdd:cookinggarlic",
|
|
||||||
"item": "minecraft:beef",
|
"item": "minecraft:beef",
|
||||||
"target": "rtdd:carrotandbeef",
|
"target": "minecraft:diamond_block",
|
||||||
"consume": 1,
|
"consume": 1,
|
||||||
"sound": "random.fizz",
|
"giveItem": "minecraft:cooked_beef",
|
||||||
"soundPitch": 0.8,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
# ===== 步骤3:胡萝卜牛肉锅 + 木剑翻炒 → 第二阶段 =====
|
|
||||||
{
|
|
||||||
"source": "rtdd:carrotandbeef",
|
|
||||||
"item": "minecraft:wooden_sword",
|
|
||||||
"target": "rtdd:carrotandbeef_1",
|
|
||||||
"consume": 0,
|
|
||||||
"stirCount": 5,
|
|
||||||
"stirCd": 1.2,
|
|
||||||
"sound": "random.fizz",
|
|
||||||
"soundPitch": 2.1,
|
|
||||||
"failMsg": "这时候翻动会不好熟的!",
|
|
||||||
},
|
|
||||||
|
|
||||||
# ===== 步骤4:第二阶段 + 木剑翻炒 → 标记熟了 =====
|
|
||||||
{
|
|
||||||
"source": "rtdd:carrotandbeef_1",
|
|
||||||
"item": "minecraft:wooden_sword",
|
|
||||||
"target": None,
|
|
||||||
"consume": 0,
|
|
||||||
"stirCount": 3,
|
|
||||||
"stirCd": 0.8,
|
|
||||||
"sound": "random.fizz",
|
|
||||||
"soundPitch": 2.1,
|
|
||||||
"onDone": "finish",
|
|
||||||
"doneMsg": "出锅啦!拿盘子盛出来",
|
|
||||||
"failMsg": "这时候翻动会不好熟的!",
|
|
||||||
"dropIfDone": ["minecraft:cooked_beef", "rtdd:wok"],
|
|
||||||
"dropIfNot": ["minecraft:beef", "rtdd:wok"],
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
@@ -88,10 +88,6 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
# ==================== 主入口:玩家右键方块 ====================
|
# ==================== 主入口:玩家右键方块 ====================
|
||||||
|
|
||||||
def OnBlockUse(self, args):
|
def OnBlockUse(self, args):
|
||||||
"""
|
|
||||||
玩家右键方块时触发。
|
|
||||||
流程:查配方 → 验条件 → 处理翻炒 → 消耗物品 → 替换方块 → 给物品 → 播声音
|
|
||||||
"""
|
|
||||||
blockName = args.get("blockName")
|
blockName = args.get("blockName")
|
||||||
playerId = args.get("playerId")
|
playerId = args.get("playerId")
|
||||||
x, y, z = args.get("x"), args.get("y"), args.get("z")
|
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):
|
def executeRecipe(self, recipe, playerId, pos, dim, itemDict):
|
||||||
# 1. 检查附加条件
|
|
||||||
if not self.checkConditions(recipe, playerId, pos, dim, itemDict):
|
if not self.checkConditions(recipe, playerId, pos, dim, itemDict):
|
||||||
return
|
return
|
||||||
|
|
||||||
# 2. 消耗物品
|
|
||||||
if recipe.get("consume", 1) > 0:
|
if recipe.get("consume", 1) > 0:
|
||||||
self.consumeItem(playerId, itemDict, recipe.get("consume", 1))
|
self.consumeItem(playerId, itemDict, recipe.get("consume", 1))
|
||||||
if recipe.get("needOil"):
|
if recipe.get("needOil"):
|
||||||
self.removeOil(itemDict, playerId)
|
self.removeOil(itemDict, playerId)
|
||||||
|
|
||||||
# 3. 替换方块
|
|
||||||
if recipe.get("target"):
|
if recipe.get("target"):
|
||||||
self.replaceBlock(pos, dim, recipe["target"], playerId)
|
self.replaceBlock(pos, dim, recipe["target"], playerId)
|
||||||
|
|
||||||
# 4. 给物品
|
|
||||||
if recipe.get("giveItem"):
|
if recipe.get("giveItem"):
|
||||||
self.giveItem(playerId, recipe["giveItem"])
|
self.giveItem(playerId, recipe["giveItem"])
|
||||||
|
|
||||||
# 5. 播放声音(需要配合 BlueFox 框架的客户端 PlaySound 事件,此处暂不实现)
|
|
||||||
|
|
||||||
# ==================== 翻炒处理 ====================
|
# ==================== 翻炒处理 ====================
|
||||||
|
|
||||||
def handleStir(self, key, recipe, playerId, pos, dim, itemDict):
|
def handleStir(self, key, recipe, playerId, pos, dim, itemDict):
|
||||||
|
|||||||
Reference in new issue
Block a user