烧烤 动物养殖 分类 转换功能 计时转换 退出重新判断tick (可用版本)
This commit is contained in:
1 parent
6686e80d22
commit
f359008ac3
6 files changed
+136
-87
No files matched your search
+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)
|
||||
Reference in new issue
Block a user