汤锅计时音效,菜谱 UI 补登记(豆腐鲑鱼汤 = 菜谱 26),非空锅被左键打碎掉落对应空锅,饮料分组碰撞箱修改

This commit is contained in:
wenhe committed 2026-09-30 16:13:37 +08:00
1 parent ed49a10930
commit c0dd6d8dbe
21 files changed
+369 -168

No files matched your search

@@ -35,7 +35,7 @@ from ....BlueFoxTools.ToolsConfig import LevelId
blockEntityDataComp = comp.CreateBlockEntityData(LevelId)
# ---- 只导入油锅自己的数据库 ----
from ..YouguoData import SWITCH_RULES, OILPOT_1, TIMER_RULES
from ..YouguoData import SWITCH_RULES, OILPOT_0, OILPOT_1, TIMER_RULES
# ---- 统一分发器 ----
from ...service.FeatureDispatcher import FeatureDispatcher
@@ -124,6 +124,20 @@ class YouguoService(BlueFoxServerSystem):
# ---- 右键冷却表 ----
self.cooldown = {}
# ---- 所有"油锅形态"方块(被左键打碎时一律掉 油锅(空)) ----
# 覆盖: 规则里出现过的 方块/产物/计时源/计时产物(含随机产物), 排除 油锅(空)本体
self.potBlocks = set()
for r in SWITCH_RULES:
self.potBlocks.add(r.get("block"))
self.potBlocks.add(r.get("target"))
for r in TIMER_RULES:
self.potBlocks.add(r.get("source"))
self.potBlocks.add(r.get("target"))
for t in (r.get("randomTargets") or ()):
self.potBlocks.add(t)
self.potBlocks.discard(None)
self.potBlocks.discard(OILPOT_0)
# ---- 注册到统一分发器 ----
FeatureDispatcher.register(self)
@@ -132,8 +146,8 @@ class YouguoService(BlueFoxServerSystem):
# ============================================================================
def getFeatureBlocks(self):
"""返回本功能管辖的所有右键方块名集合"""
return self.featureBlocks
"""返回本功能管辖的所有右键方块名集合(含锅形态, 供"打碎掉空锅"路由)"""
return self.featureBlocks | self.potBlocks
def getItemUseOnRules(self):
"""手持物品右键方块表面不需要单独路由(放料/出锅都是右键方块本身), 返回空"""
@@ -350,3 +364,48 @@ class YouguoService(BlueFoxServerSystem):
return False
self.cooldown[key] = now
return True
# ============================================================================
# 十、被左键打碎: 非空油锅一律掉 油锅(空)
# ============================================================================
def handleDestroy(self, args):
"""由 FeatureDispatcher 转发的"玩家左键破坏方块"入口。
油锅系列(除 油锅(空) 本体外)被打碎: 取消默认掉落(不掉"半成品锅"本体),
改为掉落 油锅(空)。油锅(空)本体不在 potBlocks 中, 保持默认掉自己。
返回 True=本功能处理了这次破坏; False=不归本功能管(交还默认掉落)。"""
# ServerPlayerTryDestroyBlockEvent 的方块名字段是 fullName(不是 blockName)
blockName = args.get("fullName") or args.get("blockName")
if blockName not in self.potBlocks:
return False
playerId = args.get("playerId")
x, y, z = args.get("x"), args.get("y"), args.get("z")
pos = (x, y, z)
dim = comp.CreateDimension(playerId).GetEntityDimensionId()
# 取消默认破坏+默认掉落(不让"半成品锅"本身掉出来)
args['cancel'] = True
args['spawnResources'] = False
# 记录朝向aux, 再清空方块为空气(aux必须为0)
aux = 0
try:
old = comp.CreateBlockInfo(LevelId).GetBlockNew(pos, dim)
aux = old.get("aux", 0)
except Exception:
aux = 0
try:
comp.CreateBlockInfo(LevelId).SetBlockNew(
pos, blockDict={"name": "minecraft:air", "aux": 0},
oldBlockHandling=0, dimensionId=dim)
except Exception:
pass
# 掉落 油锅(空)(保留朝向)
try:
self.CreateEngineItemEntity(
{"itemName": OILPOT_0, "count": 1, "auxValue": aux},
dim, (x, y + 0.5, z))
except Exception:
pass
return True