烧烤 动物养殖 分类 转换功能 计时转换 退出重新判断tick (可用版本)
This commit is contained in:
1 parent
6686e80d22
commit
f359008ac3
6 files changed
+136
-87
No files matched your search
+5
-5
@@ -42,7 +42,7 @@ ANIMAL_SWITCHES = [
|
||||
"target": "rtdd:chickencoop_1",
|
||||
"consume": 1,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"tip": "§a鸡蛋已放入鸡窝 (1/5)",
|
||||
"giveItem": None,
|
||||
},
|
||||
@@ -53,7 +53,7 @@ ANIMAL_SWITCHES = [
|
||||
"target": "rtdd:chickencoop_2",
|
||||
"consume": 1,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"tip": "§a鸡蛋已放入鸡窝 (2/5)",
|
||||
"giveItem": None,
|
||||
},
|
||||
@@ -64,7 +64,7 @@ ANIMAL_SWITCHES = [
|
||||
"target": "rtdd:chickencoop_3",
|
||||
"consume": 1,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"tip": "§a鸡蛋已放入鸡窝 (3/5)",
|
||||
"giveItem": None,
|
||||
},
|
||||
@@ -75,7 +75,7 @@ ANIMAL_SWITCHES = [
|
||||
"target": "rtdd:chickencoop_4",
|
||||
"consume": 1,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"tip": "§a鸡蛋已放入鸡窝 (4/5)",
|
||||
"giveItem": None,
|
||||
},
|
||||
@@ -86,7 +86,7 @@ ANIMAL_SWITCHES = [
|
||||
"target": "rtdd:chickencoop_5",
|
||||
"consume": 1,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"tip": "§a鸡蛋已放入鸡窝 (5/5)",
|
||||
"giveItem": None,
|
||||
},
|
||||
|
||||
+40
-25
@@ -221,8 +221,9 @@ class AnimalService(BlueFoxServerSystem):
|
||||
# 去重:如果该方块已经在本规则计时中,不重置(保持原剩余时间)
|
||||
try:
|
||||
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if data and data.get("rtdd_tid") == recipe["source"]:
|
||||
return
|
||||
if data:
|
||||
if data["rtdd_tid"] == recipe["source"]:
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
self._writeTimerData(dim, pos, recipe, playerId)
|
||||
@@ -232,33 +233,46 @@ class AnimalService(BlueFoxServerSystem):
|
||||
|
||||
def handleBlockEntityTick(self, args):
|
||||
"""FeatureDispatcher 转发:计时方块每 tick 检查是否到点"""
|
||||
posDim = args.get("posDim")
|
||||
if not posDim:
|
||||
return
|
||||
dim = posDim[3]
|
||||
pos = (posDim[0], posDim[1], posDim[2])
|
||||
self._tickProcess(dim, pos)
|
||||
dim = args.get("dimension")
|
||||
pos = (args.get("posX"), args.get("posY"), args.get("posZ"))
|
||||
blockName = args.get("blockName", "")
|
||||
self._tickProcess(dim, pos, blockName)
|
||||
|
||||
def _tickProcess(self, dim, pos):
|
||||
def _tickProcess(self, dim, pos, blockName):
|
||||
"""
|
||||
tick 主逻辑:读方块上记录的计时数据,到点就执行转换。
|
||||
即便服务器重启过,只要 tick 恢复,时间戳照常生效,
|
||||
比如烤制进行到 40 秒退出,回来时按原时间戳继续,只剩 20 秒。
|
||||
tick 主逻辑:
|
||||
1) 按事件自带的当前方块名判断是否计时源(创造直接放置也会进来)
|
||||
2) 是计时源但没有计时数据 → 自动补写计时(放置即开始计时)
|
||||
3) 有计时数据 → 到点执行转换(重启后时间戳照常生效)
|
||||
方块被拆掉后 tick 停止、数据随方块消失,不会在原位置继续计时转换。
|
||||
注意:GetBlockEntityData 返回的对象不支持 .get(),这里统一用 [] 读取。
|
||||
"""
|
||||
try:
|
||||
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if not data:
|
||||
return
|
||||
tid = data.get("rtdd_tid")
|
||||
if not tid:
|
||||
return
|
||||
recipe = self.animalTimers.get(tid)
|
||||
recipe = self.animalTimers.get(blockName)
|
||||
if not recipe:
|
||||
return # 当前方块不是计时源(tick 只对计时源方块开启)
|
||||
|
||||
blockData = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if blockData is None:
|
||||
return
|
||||
tstart = data.get("rtdd_tstart", 0)
|
||||
tdur = data.get("rtdd_tdur", 0)
|
||||
|
||||
# 读取计时标识;没有或与当前方块不符
|
||||
try:
|
||||
tid = blockData["rtdd_tid"]
|
||||
except Exception:
|
||||
tid = ""
|
||||
if tid != blockName:
|
||||
# 放置即自动计时:默认开启(饲料盆/饲料槽)
|
||||
# 烧烤(autoStart=False)必须右键激活,这里不补写
|
||||
if recipe.get("autoStart", True):
|
||||
self._writeTimerData(dim, pos, recipe, None)
|
||||
return
|
||||
|
||||
tstart = blockData["rtdd_tstart"]
|
||||
tdur = blockData["rtdd_tdur"]
|
||||
|
||||
if time.time() - tstart >= tdur:
|
||||
self._finishTimer(dim, pos, recipe, data)
|
||||
self._finishTimer(dim, pos, recipe, blockData)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -279,13 +293,13 @@ class AnimalService(BlueFoxServerSystem):
|
||||
nextRecipe = self.animalTimers.get(recipe["target"])
|
||||
if nextRecipe:
|
||||
# 下一级计时(换新的开始时间戳)
|
||||
self._writeTimerData(dim, pos, nextRecipe, data.get("rtdd_tp"))
|
||||
self._writeTimerData(dim, pos, nextRecipe, data["rtdd_tp"])
|
||||
else:
|
||||
# 整条链结束:清数据 + 完成提示
|
||||
self._clearTimerData(dim, pos)
|
||||
doneTip = recipe.get("doneTip")
|
||||
if doneTip:
|
||||
self._notifyIfOnline(data.get("rtdd_tp"), doneTip)
|
||||
self._notifyIfOnline(data["rtdd_tp"], doneTip)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -297,8 +311,9 @@ class AnimalService(BlueFoxServerSystem):
|
||||
blockData = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if blockData is None:
|
||||
return
|
||||
now = time.time()
|
||||
blockData["rtdd_tid"] = recipe["source"]
|
||||
blockData["rtdd_tstart"] = time.time()
|
||||
blockData["rtdd_tstart"] = now
|
||||
blockData["rtdd_tdur"] = recipe.get("time", 60)
|
||||
blockData["rtdd_tp"] = playerId if playerId else ""
|
||||
except Exception:
|
||||
|
||||
+19
@@ -58,6 +58,22 @@ blockEntityDataComp = comp.CreateBlockEntityData(LevelId)
|
||||
# RECIPES 是一个列表,每条配方是一个 dict,格式见 RecipeData.py 顶部注释
|
||||
from ..RecipeData import RECIPES, inferBaseBlock, BELOW_CAMPFIRE
|
||||
|
||||
# ---- 已由 FeatureDispatcher/BarbecueService 接管的烧烤方块 ----
|
||||
# 这些方块属于"烧烤"(xy_barbecue) 分类,由新系统处理(支杆+营火机制),
|
||||
# 做菜系统必须跳过,否则右键烤乳猪(熟)等会被当成菜谱去查灶台底座,弹出错误提示。
|
||||
_BARBECUE_OWNED = set([
|
||||
"rtdd:barbecuegrill_0", "rtdd:barbecuegrill_1",
|
||||
"rtdd:roastpig_0", "rtdd:roastpig_1",
|
||||
"rtdd:roastchicken_0", "rtdd:roastchicken_1",
|
||||
"rtdd:roastchickenplace_0",
|
||||
"rtdd:grilledcod_0", "rtdd:grilledcod_1",
|
||||
"rtdd:grilled_fish", "rtdd:grilled_salmon",
|
||||
"rtdd:roasted_vegetables_0", "rtdd:roasted_vegetables_1", "rtdd:roasted_vegetables_3",
|
||||
"rtdd:roastedmushrooms_0", "rtdd:roastedmushrooms_1", "rtdd:roastedmushrooms_3",
|
||||
"rtdd:beefkebabs_0", "rtdd:beefkebabs_1", "rtdd:beefkebabs_3",
|
||||
"rtdd:lambkebabs_0", "rtdd:lambkebabs_1", "rtdd:lambkebabs_3",
|
||||
])
|
||||
|
||||
# ================================================================================
|
||||
# 工具函数:读取物品 userData 里的嵌套字段
|
||||
# ================================================================================
|
||||
@@ -141,8 +157,11 @@ class CookingService(BlueFoxServerSystem):
|
||||
# ---- 构建做菜方块名集合(O(1) 快速拦截,第一道过滤) ----
|
||||
# 事件进来先判断方块名在不在这个集合里,不在直接 return,
|
||||
# 这样工具方块的右键事件根本不会进到本系统的字典查找
|
||||
# 注意:跳过已由 BarbecueService 接管的烧烤方块,避免做菜系统抢事件
|
||||
self.cookBlockSet = set()
|
||||
for recipe in RECIPES:
|
||||
if recipe["source"] in _BARBECUE_OWNED:
|
||||
continue
|
||||
self.cookBlockSet.add(recipe["source"])
|
||||
|
||||
def Destroy(self):
|
||||
|
||||
+11
-16
@@ -201,28 +201,23 @@ class FeatureDispatcher(BlueFoxServerSystem):
|
||||
|
||||
def OnBlockEntityTick(self, args):
|
||||
"""
|
||||
配置了 tick:true 的方块每帧触发。
|
||||
配置了 tick:true 的方块每帧触发(官方频率约每秒20次)。
|
||||
用于"烤制/饲料变空"等计时转换的持久化:
|
||||
- 转换开始时把 开始时间戳+时长 写进方块实体数据
|
||||
- 服务器重启/玩家重进后,tick 恢复,读回时间戳继续计时,
|
||||
到点即转换(例如烤鸡烤了40秒退出,回来只剩20秒)
|
||||
按方块实体数据里的计时标识 rtdd_tid 路由到对应功能服务。
|
||||
|
||||
注意:该事件参数是 blockName/dimension/posX/posY/posZ(不是 posDim!)
|
||||
直接用事件自带的 blockName 路由,省掉每帧读方块,性能更好。
|
||||
"""
|
||||
posDim = args.get("posDim")
|
||||
if not posDim:
|
||||
posX = args.get("posX")
|
||||
posY = args.get("posY")
|
||||
posZ = args.get("posZ")
|
||||
dimension = args.get("dimension")
|
||||
if posX is None or posY is None or posZ is None or dimension is None:
|
||||
return
|
||||
dim = posDim[3]
|
||||
pos = (posDim[0], posDim[1], posDim[2])
|
||||
try:
|
||||
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if not data:
|
||||
return
|
||||
tid = data.get("rtdd_tid") # 计时标识 = 计时源方块名
|
||||
except Exception:
|
||||
return
|
||||
if not tid:
|
||||
return
|
||||
service = self.blockOwner.get(tid) # 计时源方块一定注册在路由表里
|
||||
blockName = args.get("blockName", "")
|
||||
service = self.blockOwner.get(blockName) # 计时源方块一定注册在路由表里
|
||||
if not service:
|
||||
return
|
||||
service.handleBlockEntityTick(args)
|
||||
+18
-12
@@ -36,6 +36,7 @@
|
||||
tip: 转换成功时给玩家的提示(绿色§a开头)
|
||||
startTip: 计时型规则启动计时时给玩家的提示(仅玩家主动触发时发)
|
||||
doneTip: 计时到点完成时给启动者的提示(如"烤鸡烤熟了!")
|
||||
autoStart: 放置时是否自动开始计时,默认True(自动);烧烤烤制设为False=必须右键激活
|
||||
================================================================================
|
||||
"""
|
||||
|
||||
@@ -88,7 +89,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:beefkebabs_0",
|
||||
"consume": 0,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"below": ["rtdd:barbecuegrill_1"],
|
||||
"tip": "§a牛肉串正在翻烤…",
|
||||
"giveItem": None,
|
||||
@@ -99,7 +100,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:beefkebabs_3",
|
||||
"consume": 0,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"below": ["rtdd:barbecuegrill_1"],
|
||||
"tip": "§e牛肉串烤熟了!",
|
||||
"giveItem": None,
|
||||
@@ -111,7 +112,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:lambkebabs_0",
|
||||
"consume": 0,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"below": ["rtdd:barbecuegrill_1"],
|
||||
"tip": "§a羊肉串正在翻烤…",
|
||||
"giveItem": None,
|
||||
@@ -122,7 +123,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:lambkebabs_3",
|
||||
"consume": 0,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"below": ["rtdd:barbecuegrill_1"],
|
||||
"tip": "§e羊肉串烤熟了!",
|
||||
"giveItem": None,
|
||||
@@ -134,7 +135,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:roasted_vegetables_1",
|
||||
"consume": 0,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"below": ["rtdd:barbecuegrill_1"],
|
||||
"tip": "§a烤蔬菜串正在翻烤…",
|
||||
"giveItem": None,
|
||||
@@ -145,7 +146,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:roasted_vegetables_3",
|
||||
"consume": 0,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"below": ["rtdd:barbecuegrill_1"],
|
||||
"tip": "§e烤蔬菜串烤熟了!",
|
||||
"giveItem": None,
|
||||
@@ -157,7 +158,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:roastedmushrooms_1",
|
||||
"consume": 0,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"below": ["rtdd:barbecuegrill_1"],
|
||||
"tip": "§a烤香菇串正在翻烤…",
|
||||
"giveItem": None,
|
||||
@@ -168,7 +169,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:roastedmushrooms_3",
|
||||
"consume": 0,
|
||||
"type": "switch",
|
||||
"switchCd": 0.15,
|
||||
"switchCd": 0.5,
|
||||
"below": ["rtdd:barbecuegrill_1"],
|
||||
"tip": "§e烤香菇串烤熟了!",
|
||||
"giveItem": None,
|
||||
@@ -184,7 +185,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:roastchicken_0",
|
||||
"consume": 1,
|
||||
"type": "switch",
|
||||
"tip": "§a烤鸡已上杆,等待篝火烤制…",
|
||||
"tip": "§a烤鸡已上杆,右键开始烤制",
|
||||
"giveItem": None,
|
||||
},
|
||||
# 【上烤乳猪】支杆 + 死猪 → 烤乳猪(生)
|
||||
@@ -194,7 +195,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:roastpig_0",
|
||||
"consume": 1,
|
||||
"type": "switch",
|
||||
"tip": "§a烤乳猪已上杆,等待篝火烤制…",
|
||||
"tip": "§a烤乳猪已上杆,右键开始烤制",
|
||||
"giveItem": None,
|
||||
},
|
||||
# 【上烤鳕鱼】支杆 + 鳕鱼 → 烤鳕鱼(生)
|
||||
@@ -204,7 +205,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:grilledcod_0",
|
||||
"consume": 1,
|
||||
"type": "switch",
|
||||
"tip": "§a烤鳕鱼已上杆,等待篝火烤制…",
|
||||
"tip": "§a烤鳕鱼已上杆,右键开始烤制",
|
||||
"giveItem": None,
|
||||
},
|
||||
# 【上烤鲑鱼】支杆 + 鲑鱼 → 烤鲑鱼(生)
|
||||
@@ -214,7 +215,7 @@ BARBECUE_SWITCHES = [
|
||||
"target": "rtdd:grilled_fish",
|
||||
"consume": 1,
|
||||
"type": "switch",
|
||||
"tip": "§a烤鲑鱼已上杆,等待篝火烤制…",
|
||||
"tip": "§a烤鲑鱼已上杆,右键开始烤制",
|
||||
"giveItem": None,
|
||||
},
|
||||
|
||||
@@ -222,6 +223,7 @@ BARBECUE_SWITCHES = [
|
||||
# 四、计时烤制(上杆后,支杆下方篝火,计时自动转换)
|
||||
# ============================================================
|
||||
# 【烤熟】烤鸡(上烤架_生) → 烤鸡(上烤架_熟),下方需篝火,约60秒
|
||||
# autoStart=False:放置/上杆后必须右键一下才开始烤制
|
||||
{
|
||||
"source": "rtdd:roastchicken_0",
|
||||
"item": None,
|
||||
@@ -230,6 +232,7 @@ BARBECUE_SWITCHES = [
|
||||
"type": "timer",
|
||||
"time": 60,
|
||||
"below": ["minecraft:campfire"],
|
||||
"autoStart": False,
|
||||
"startTip": "§e开始烤制烤鸡,约60秒…",
|
||||
"doneTip": "§e烤鸡烤熟了!",
|
||||
"giveItem": None,
|
||||
@@ -243,6 +246,7 @@ BARBECUE_SWITCHES = [
|
||||
"type": "timer",
|
||||
"time": 60,
|
||||
"below": ["minecraft:campfire"],
|
||||
"autoStart": False,
|
||||
"startTip": "§e开始烤制烤乳猪,约60秒…",
|
||||
"doneTip": "§e烤乳猪烤熟了!",
|
||||
"giveItem": None,
|
||||
@@ -256,6 +260,7 @@ BARBECUE_SWITCHES = [
|
||||
"type": "timer",
|
||||
"time": 60,
|
||||
"below": ["minecraft:campfire"],
|
||||
"autoStart": False,
|
||||
"startTip": "§e开始烤制烤鳕鱼,约60秒…",
|
||||
"doneTip": "§e烤鳕鱼烤熟了!",
|
||||
"giveItem": None,
|
||||
@@ -269,6 +274,7 @@ BARBECUE_SWITCHES = [
|
||||
"type": "timer",
|
||||
"time": 60,
|
||||
"below": ["minecraft:campfire"],
|
||||
"autoStart": False,
|
||||
"startTip": "§e开始烤制烤鲑鱼,约60秒…",
|
||||
"doneTip": "§e烤鲑鱼烤熟了!",
|
||||
"giveItem": None,
|
||||
|
||||
+43
-29
@@ -221,12 +221,8 @@ class BarbecueService(BlueFoxServerSystem):
|
||||
if recipe.get("giveItem"):
|
||||
self.giveItem(playerId, recipe["giveItem"], recipe.get("giveCount", 1))
|
||||
|
||||
# 上杆后若新方块是计时源 → 尝试启动计时(下方需有篝火)
|
||||
if recipe.get("target") in self.barbecueTimers:
|
||||
nextTimer = self.barbecueTimers[recipe["target"]]
|
||||
if self.checkBelow(nextTimer, dim, pos):
|
||||
self.startTimer(key, nextTimer, dim, playerId)
|
||||
|
||||
# 注意:上杆/点火后【不自动启动烤制】。
|
||||
# 烤制规则 autoStart=False,必须玩家右键烤制方块才激活计时(见 handleBlockUse)
|
||||
# 转换成功提示(点火/上杆等)
|
||||
if recipe.get("tip"):
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(playerId, recipe["tip"])
|
||||
@@ -277,8 +273,9 @@ class BarbecueService(BlueFoxServerSystem):
|
||||
# 去重:已在本规则计时中的方块不重置
|
||||
try:
|
||||
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if data and data.get("rtdd_tid") == recipe["source"]:
|
||||
return
|
||||
if data:
|
||||
if data["rtdd_tid"] == recipe["source"]:
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
self._writeTimerData(dim, pos, recipe, playerId)
|
||||
@@ -288,29 +285,45 @@ class BarbecueService(BlueFoxServerSystem):
|
||||
|
||||
def handleBlockEntityTick(self, args):
|
||||
"""FeatureDispatcher 转发:烤制方块每 tick 检查是否到点"""
|
||||
posDim = args.get("posDim")
|
||||
if not posDim:
|
||||
return
|
||||
dim = posDim[3]
|
||||
pos = (posDim[0], posDim[1], posDim[2])
|
||||
self._tickProcess(dim, pos)
|
||||
dim = args.get("dimension")
|
||||
pos = (args.get("posX"), args.get("posY"), args.get("posZ"))
|
||||
blockName = args.get("blockName", "")
|
||||
self._tickProcess(dim, pos, blockName)
|
||||
|
||||
def _tickProcess(self, dim, pos):
|
||||
"""tick 主逻辑:读计时数据,到点执行转换(重启后照样生效)"""
|
||||
def _tickProcess(self, dim, pos, blockName):
|
||||
"""
|
||||
tick 主逻辑:
|
||||
1) 按事件自带的当前方块名判断是否计时源(创造直接放置也会进来)
|
||||
2) 是计时源但没有计时数据 → 自动补写计时(放置即开始计时)
|
||||
3) 有计时数据 → 到点执行转换(重启后时间戳照常生效)
|
||||
方块被拆掉后 tick 停止、数据随方块消失,不会在原位置继续计时转换。
|
||||
注意:GetBlockEntityData 返回的对象不支持 .get(),这里统一用 [] 读取。
|
||||
"""
|
||||
try:
|
||||
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if not data:
|
||||
return
|
||||
tid = data.get("rtdd_tid")
|
||||
if not tid:
|
||||
return
|
||||
recipe = self.barbecueTimers.get(tid)
|
||||
recipe = self.barbecueTimers.get(blockName)
|
||||
if not recipe:
|
||||
return # 当前方块不是计时源(tick 只对计时源方块开启)
|
||||
|
||||
blockData = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if blockData is None:
|
||||
return
|
||||
tstart = data.get("rtdd_tstart", 0)
|
||||
tdur = data.get("rtdd_tdur", 0)
|
||||
|
||||
# 读取计时标识;没有或与当前方块不符
|
||||
try:
|
||||
tid = blockData["rtdd_tid"]
|
||||
except Exception:
|
||||
tid = ""
|
||||
if tid != blockName:
|
||||
# 烧烤必须右键激活烤制:autoStart=False 时不自动补写计时
|
||||
if recipe.get("autoStart", True):
|
||||
self._writeTimerData(dim, pos, recipe, None)
|
||||
return
|
||||
|
||||
tstart = blockData["rtdd_tstart"]
|
||||
tdur = blockData["rtdd_tdur"]
|
||||
|
||||
if time.time() - tstart >= tdur:
|
||||
self._finishTimer(dim, pos, recipe, data)
|
||||
self._finishTimer(dim, pos, recipe, blockData)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -330,12 +343,12 @@ class BarbecueService(BlueFoxServerSystem):
|
||||
self.replaceBlock(pos, dim, recipe["target"], None)
|
||||
nextRecipe = self.barbecueTimers.get(recipe["target"])
|
||||
if nextRecipe:
|
||||
self._writeTimerData(dim, pos, nextRecipe, data.get("rtdd_tp"))
|
||||
self._writeTimerData(dim, pos, nextRecipe, data["rtdd_tp"])
|
||||
else:
|
||||
self._clearTimerData(dim, pos)
|
||||
doneTip = recipe.get("doneTip")
|
||||
if doneTip:
|
||||
self._notifyIfOnline(data.get("rtdd_tp"), doneTip)
|
||||
self._notifyIfOnline(data["rtdd_tp"], doneTip)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -347,8 +360,9 @@ class BarbecueService(BlueFoxServerSystem):
|
||||
blockData = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if blockData is None:
|
||||
return
|
||||
now = time.time()
|
||||
blockData["rtdd_tid"] = recipe["source"]
|
||||
blockData["rtdd_tstart"] = time.time()
|
||||
blockData["rtdd_tstart"] = now
|
||||
blockData["rtdd_tdur"] = recipe.get("time", 60)
|
||||
blockData["rtdd_tp"] = playerId if playerId else ""
|
||||
except Exception:
|
||||
|
||||
Reference in new issue
Block a user