汤锅功能实现 2
This commit is contained in:
1 parent
30ac368690
commit
25b023b703
5 files changed
+82
-29
No files matched your search
+32
-3
@@ -33,7 +33,7 @@ from ....BlueFoxTools.SpecialFunciton.BlueFoxSystem import BlueFoxServerSystem
|
||||
from ....BlueFoxTools.ToolsConfig import LevelId
|
||||
|
||||
# ---- 只导入汤锅自己的数据库 ----
|
||||
from ..TangguoData import SWITCH_RULES
|
||||
from ..TangguoData import SWITCH_RULES, ITEM_USE_ON_RULES
|
||||
|
||||
# ---- 统一分发器 ----
|
||||
from ...service.FeatureDispatcher import FeatureDispatcher
|
||||
@@ -55,6 +55,11 @@ class TangguoService(BlueFoxServerSystem):
|
||||
self.recipes[(r["block"], r.get("item"))] = r
|
||||
self.featureBlocks.add(r["block"])
|
||||
|
||||
# ---- 手持锅态汤方块右键 熟面条表面 -> 规则: (物品, 表面方块) -> 规则 ----
|
||||
self.itemUseOnRecipes = {}
|
||||
for r in ITEM_USE_ON_RULES:
|
||||
self.itemUseOnRecipes[(r["item"], r["surface"])] = r
|
||||
|
||||
# ---- 右键冷却表 ----
|
||||
self.cooldown = {}
|
||||
|
||||
@@ -70,8 +75,9 @@ class TangguoService(BlueFoxServerSystem):
|
||||
return self.featureBlocks
|
||||
|
||||
def getItemUseOnRules(self):
|
||||
"""手持物品右键方块表面不需要单独路由(所有转换都是右键方块本身), 返回空"""
|
||||
return {}
|
||||
"""手持锅态汤方块(蘑菇汤/蔬菜汤/蛋花汤)右键 熟面条表面 走 itemUseOn 路径,
|
||||
在同一个事件里完成转换+取消放置, 防止引擎把"锅"放出来/掉出来"""
|
||||
return {r["item"]: True for r in ITEM_USE_ON_RULES}
|
||||
|
||||
def handleBlockUse(self, args):
|
||||
"""由 FeatureDispatcher 转发的右键方块入口"""
|
||||
@@ -94,6 +100,29 @@ class TangguoService(BlueFoxServerSystem):
|
||||
self.handleSwitch(recipe, playerId, pos, dim, itemDict)
|
||||
return True
|
||||
|
||||
def handleItemUseOn(self, args):
|
||||
"""由 FeatureDispatcher 转发的"手持物品右键方块表面"入口(锅态汤面)。
|
||||
手持 蘑菇汤/蔬菜汤/蛋花汤 右键 熟面条表面 -> 汤面, 转换与取消放置同一事件完成"""
|
||||
itemName = args.get("itemName")
|
||||
playerId = args.get("playerId") or args.get("entityId")
|
||||
x, y, z = args.get("x"), args.get("y"), args.get("z")
|
||||
pos = (x, y, z)
|
||||
dim = comp.CreateDimension(playerId).GetEntityDimensionId()
|
||||
key = (dim, x, y, z)
|
||||
try:
|
||||
b = comp.CreateBlockInfo(LevelId).GetBlockNew(pos, dim)
|
||||
clickedName = b.get("name") if b else None
|
||||
except Exception:
|
||||
clickedName = None
|
||||
recipe = self.itemUseOnRecipes.get((itemName, clickedName))
|
||||
if not recipe:
|
||||
return False
|
||||
if not self.checkCooldown(key, 0.4):
|
||||
return True
|
||||
itemDict = self.getCarriedItem(playerId)
|
||||
self.handleSwitch(recipe, playerId, pos, dim, itemDict)
|
||||
return True
|
||||
|
||||
# ============================================================================
|
||||
# 二、通用转换执行
|
||||
# ============================================================================
|
||||
|
||||
Reference in new issue
Block a user