汤锅计时音效,菜谱 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

@@ -83,6 +83,20 @@ class ChaoguoService(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(WOK)
# ---- 注册到统一分发器 ----
FeatureDispatcher.register(self)
@@ -91,8 +105,8 @@ class ChaoguoService(BlueFoxServerSystem):
# ============================================================================
def getFeatureBlocks(self):
"""返回本功能管辖的所有右键方块名集合"""
return self.featureBlocks
"""返回本功能管辖的所有右键方块名集合(含锅形态, 供"打碎掉空锅"路由)"""
return self.featureBlocks | self.potBlocks
def getItemUseOnRules(self):
"""手持物品右键方块表面路由: 盖饭成品菜 + 米饭三形态(盖饭/蛋炒饭)"""
@@ -410,3 +424,48 @@ class ChaoguoService(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": WOK, "count": 1, "auxValue": aux},
dim, (x, y + 0.5, z))
except Exception:
pass
return True
@@ -36,7 +36,7 @@ from ....BlueFoxTools.ToolsConfig import LevelId
blockEntityDataComp = comp.CreateBlockEntityData(LevelId)
# ---- 只导入汤锅自己的数据库 ----
from ..TangguoData import SWITCH_RULES, ITEM_USE_ON_RULES, TIMER_RULES, BOWL, PLATE
from ..TangguoData import SWITCH_RULES, ITEM_USE_ON_RULES, TIMER_RULES, BOWL, PLATE, POT_EMPTY
# ---- 统一分发器 ----
from ...service.FeatureDispatcher import FeatureDispatcher
@@ -136,6 +136,20 @@ class TangguoService(BlueFoxServerSystem):
self.timerSources.add(src)
self.featureBlocks.add(src) # 登记右键路由, 空手右键才分发到这里
# ---- 所有"汤锅形态"方块(被左键打碎时一律掉 汤锅(空)) ----
# 覆盖: 规则里出现过的 方块/产物/计时源/计时产物(含随机产物), 排除 汤锅(空)本体
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(POT_EMPTY)
# ---- 右键冷却表 ----
self.cooldown = {}
@@ -147,8 +161,8 @@ class TangguoService(BlueFoxServerSystem):
# ============================================================================
def getFeatureBlocks(self):
"""返回本功能管辖的所有右键方块名集合"""
return self.featureBlocks
"""返回本功能管辖的所有右键方块名集合(含锅形态, 供"打碎掉空锅"路由)"""
return self.featureBlocks | self.potBlocks
def getItemUseOnRules(self):
"""手持锅态汤方块(蘑菇汤/蔬菜汤/蛋花汤)右键 熟面条表面 走 itemUseOn 路径,
@@ -389,3 +403,48 @@ class TangguoService(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": POT_EMPTY, "count": 1, "auxValue": aux},
dim, (x, y + 0.5, z))
except Exception:
pass
return True
@@ -42,6 +42,9 @@ from ..TangguoData import TIMER_RULES
# ---- 统一分发器 ----
from ...service.FeatureDispatcher import FeatureDispatcher
# ---- 全服播放音效(计时到点: 咕嘟声 bubble.up) ----
from ....ModUtil.ServerUtil import PlaySoundToAllClient
class TangguoTimerService(BlueFoxServerSystem):
"""
@@ -170,6 +173,8 @@ class TangguoTimerService(BlueFoxServerSystem):
else:
target = rule["target"]
self.replaceBlock(pos, dim, target, None)
# 计时到点: 全服播放"咕嘟"声(bubble.up) —— 每一级转换都播
PlaySoundToAllClient((pos[0], pos[1], pos[2], dim), "bubble.up", 1.0)
self._clearTimerData(dim, pos)
except Exception:
pass
@@ -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