搬运了原版食材 死亡生物 手办 功能实现 无bug (可用版本)

This commit is contained in:
wenhe committed 2026-09-02 19:42:12 +08:00
1 parent 213c74cb55
commit 1f329f8b4c
10 files changed
+78 -4

No files matched your search

@@ -458,3 +458,11 @@ DEADMOB_SWITCHES = [
"giveItem": None,
},
]
# 晾晒计时源方块(挂上鱼后变成这些方块, tick 自动开始晾干):
# 用于挂鱼时记录玩家, 晾干完成时把 doneTip 发给该玩家。
DRY_SOURCE_BLOCKS = {
"rtdd:hang_meat_hooks_1",
"rtdd:hang_meat_hooks_2",
"rtdd:meathookcod_2",
}
@@ -41,8 +41,11 @@ comp = serverApi.GetEngineCompFactory() # 组件工厂
from ....BlueFoxTools.SpecialFunciton.BlueFoxSystem import BlueFoxServerSystem
from ....BlueFoxTools.ToolsConfig import LevelId
# ---- 方块实体数据组件(记录挂鱼玩家, 晾干完成时通知) ----
blockEntityDataComp = comp.CreateBlockEntityData(LevelId)
# ---- 只导入死亡生物自己的数据库 ----
from ..DeadmobData import DEADMOB_SWITCHES
from ..DeadmobData import DEADMOB_SWITCHES, DRY_SOURCE_BLOCKS
# ---- 统一分发器 ----
from ...service.FeatureDispatcher import FeatureDispatcher
@@ -173,11 +176,35 @@ class DeadmobService(BlueFoxServerSystem):
# ---- 替换方块 ----
if recipe.get("target"):
self.replaceBlock(pos, dim, recipe["target"], playerId)
# 挂鱼后目标变成"晾晒计时源" → 记录挂鱼玩家, 晾干完成时通知该玩家
if recipe.get("target") in DRY_SOURCE_BLOCKS:
self.recordDryingPlayer(pos, dim, playerId)
# ---- 转换成功提示 ----
if recipe.get("tip"):
comp.CreateMsg(playerId).NotifyOneMessage(playerId, recipe["tip"])
# ============================================================================
# 四、工具方法:记录晾晒玩家(挂鱼时写入方块实体, 供计时完成通知)
# ============================================================================
def recordDryingPlayer(self, pos, dim, playerId):
"""挂鱼后延迟0.1秒把玩家写入新方块实体数据, 晾干完成时通知该玩家。
SetBlockNew 后新方块 block entity 需要初始化时间, 立即写可能失败。"""
try:
comp.CreateGame(LevelId).AddTimer(0.1, self._writeDryingPlayer, pos, dim, playerId)
except Exception:
pass
def _writeDryingPlayer(self, pos, dim, playerId):
"""延迟写回调:把玩家写入方块实体数据的 rtdd_tp 字段"""
try:
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
if data is not None:
data["rtdd_tp"] = playerId
except Exception:
pass
# ============================================================================
# 四、工具方法:获取玩家主手物品
# ============================================================================
@@ -147,7 +147,6 @@ class DeadmobTimerService(BlueFoxServerSystem):
# 鱼晾干 autoStart=True:挂上后自动补写计时
if recipe.get("autoStart", True):
self._writeTimerData(dim, pos, recipe, None)
print "[Deadmob-Tick-Start]", blockName, pos
return
tstart = blockData["rtdd_tstart"]
@@ -172,7 +171,6 @@ class DeadmobTimerService(BlueFoxServerSystem):
return
# 替换方块
self.replaceBlock(pos, dim, recipe["target"], None)
print "[Deadmob-Tick-Finish]", recipe["source"], "->", recipe["target"], pos
nextRecipe = self.deadmobTimers.get(recipe["target"])
if nextRecipe:
# 下一级计时(换新的开始时间戳)
@@ -200,7 +198,15 @@ class DeadmobTimerService(BlueFoxServerSystem):
blockData["rtdd_tid"] = recipe["source"]
blockData["rtdd_tstart"] = now
blockData["rtdd_tdur"] = recipe.get("time", 300)
blockData["rtdd_tp"] = playerId if playerId else ""
# 挂鱼时 DeadmobService 已把玩家写进 rtdd_tp;这里没传玩家则保留,
# 保证晾干完成能通知到挂鱼的玩家(创造直接放没有玩家, 不提示)
if playerId:
blockData["rtdd_tp"] = playerId
else:
try:
_ = blockData["rtdd_tp"]
except Exception:
blockData["rtdd_tp"] = ""
except Exception:
pass
@@ -0,0 +1,11 @@
{
"format_version": "1.10",
"minecraft:item": {
"description": {
"identifier": "rtdd:grape"
},
"components": {
"minecraft:icon": "grape"
}
}
}
@@ -0,0 +1,11 @@
{
"format_version": "1.10",
"minecraft:item": {
"description": {
"identifier": "rtdd:orange"
},
"components": {
"minecraft:icon": "orange"
}
}
}
@@ -0,0 +1,11 @@
{
"format_version": "1.10",
"minecraft:item": {
"description": {
"identifier": "rtdd:peach"
},
"components": {
"minecraft:icon": "peach"
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

File renamed without changes.