寿司 功能实现 2
This commit is contained in:
1 parent
b82391c5c9
commit
d13a3600f1
4 files changed
+45
-26
No files matched your search
+41
-25
@@ -16,7 +16,7 @@
|
||||
├─ _handleCut ← 手持菜刀右键卷寿司两次 -> 寿司块(三个)
|
||||
└─ handleSwitch ← 通用转换(基础组/加鱼/卷制/手握/寿司堆/递减)
|
||||
handleItemUseOn ← 入口:手持饭团右键方块表面 -> 放置 手握普通寿司
|
||||
(通用工具) getCarriedItem / consumeItem / giveItem / replaceBlock /
|
||||
(通用工具) getCarriedItem / consumeItem / dropItem / replaceBlock /
|
||||
checkCooldown
|
||||
================================================================================
|
||||
"""
|
||||
@@ -99,13 +99,13 @@ class ShousiService(BlueFoxServerSystem):
|
||||
"target": g["pile3"], "consume": STACK_CONSUME,
|
||||
"tip": g.get("pileTip"),
|
||||
}
|
||||
# 递减: 空手右键, 每级取走一个, 退回卷寿司
|
||||
# 递减: 空手右键, 每级取走一个, 以掉落物形式退回卷寿司
|
||||
self.recipes[(g["pile3"], None)] = {
|
||||
"target": g["pile2"], "give": roll[-1],
|
||||
"target": g["pile2"], "drop": roll[-1],
|
||||
"tip": g.get("takeTip"),
|
||||
}
|
||||
self.recipes[(g["pile2"], None)] = {
|
||||
"target": roll[-1], "give": roll[-1],
|
||||
"target": roll[-1], "drop": roll[-1],
|
||||
"tip": g.get("takeTip"),
|
||||
}
|
||||
self.featureBlocks.add(g["pile2"])
|
||||
@@ -180,22 +180,32 @@ class ShousiService(BlueFoxServerSystem):
|
||||
return True
|
||||
|
||||
def handleItemUseOn(self, args):
|
||||
"""由 FeatureDispatcher 转发的"手持物品右键方块表面"入口(饭团放置):
|
||||
手持饭团右键任意非寿司方块表面 -> 在表面上方放置 手握普通寿司。
|
||||
"""由 FeatureDispatcher 转发的"手持物品右键方块表面"入口:
|
||||
1) 手持寿司方块物品 右键自家寿司方块 -> 取消默认放置(返回True), 交给
|
||||
handleBlockUse 处理(堆叠/卷制/加鱼/递减), 避免引擎先"放置"掉手持物品。
|
||||
2) 手持饭团右键任意非寿司方块表面 -> 在表面上方放置 手握普通寿司。
|
||||
返回 True=处理了; False=不属本功能管(交还其他服务/默认行为)。"""
|
||||
itemName = args.get("itemName")
|
||||
if itemName != RICE_BALL:
|
||||
return False
|
||||
playerId = args.get("playerId") or args.get("entityId")
|
||||
x, y, z = args.get("x"), args.get("y"), args.get("z")
|
||||
dim = comp.CreateDimension(playerId).GetEntityDimensionId()
|
||||
|
||||
# 被点方块若归寿司管辖(干海带/寿司等), 交给方块右键逻辑, 不在此放置
|
||||
# 被点方块名(用于区分"自家寿司方块"与"普通地面")
|
||||
clickedName = None
|
||||
try:
|
||||
cur = comp.CreateBlockInfo(LevelId).GetBlockNew((x, y, z), dim)
|
||||
if not cur or cur.get("name") in self.featureBlocks:
|
||||
return False
|
||||
clickedName = cur.get("name") if cur else None
|
||||
except Exception:
|
||||
clickedName = None
|
||||
|
||||
# 1) 手持寿司方块物品 右键 自家寿司方块: 取消默认放置
|
||||
if itemName in self.sushiBlockItems and clickedName in self.featureBlocks:
|
||||
return True
|
||||
|
||||
# 2) 饭团放置: 只对"非寿司方块"表面生效
|
||||
if itemName != RICE_BALL:
|
||||
return False
|
||||
if not clickedName or clickedName in self.featureBlocks:
|
||||
return False
|
||||
|
||||
# 目标格 = 被点方块上方一格, 必须为空
|
||||
@@ -281,15 +291,15 @@ class ShousiService(BlueFoxServerSystem):
|
||||
serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
|
||||
|
||||
# ============================================================================
|
||||
# 六、工具方法:给玩家物品
|
||||
# 六、工具方法:以掉落物形式生成物品(递减取走返还)
|
||||
# ============================================================================
|
||||
|
||||
def giveItem(self, playerId, itemName, count=1, aux=0):
|
||||
def dropItem(self, dim, pos, itemName, count=1, aux=0):
|
||||
try:
|
||||
itemDict = {"itemName": itemName, "count": count, "auxValue": aux}
|
||||
comp.CreateItem(playerId).SpawnItemToPlayerInv(itemDict, playerId)
|
||||
except Exception:
|
||||
pass
|
||||
self.CreateEngineItemEntity(itemDict, dim, (pos[0], pos[1] + 0.5, pos[2]))
|
||||
except Exception as e:
|
||||
print "[Shousi-dropItem] FAIL", itemName, e
|
||||
|
||||
# ============================================================================
|
||||
# 七、工具方法:消耗物品
|
||||
@@ -300,17 +310,23 @@ class ShousiService(BlueFoxServerSystem):
|
||||
return
|
||||
count = itemDict.get("count", 0)
|
||||
if count <= amount:
|
||||
comp.CreateItem(playerId).SetEntityItem(
|
||||
serverApi.GetMinecraftEnum().ItemPosType.CARRIED,
|
||||
{"itemName": "minecraft:air", "count": 0, "auxValue": 0})
|
||||
try:
|
||||
comp.CreateItem(playerId).SetEntityItem(
|
||||
serverApi.GetMinecraftEnum().ItemPosType.CARRIED,
|
||||
{"itemName": "minecraft:air", "count": 0, "auxValue": 0})
|
||||
except Exception as e:
|
||||
print "[Shousi-consume] FAIL air", e
|
||||
else:
|
||||
itemDict["count"] = count - amount
|
||||
comp.CreateItem(playerId).SetEntityItem(
|
||||
serverApi.GetMinecraftEnum().ItemPosType.CARRIED,
|
||||
{"itemName": itemDict["newItemName"],
|
||||
"count": itemDict["count"],
|
||||
"auxValue": itemDict.get("newAuxValue", 0),
|
||||
"userData": itemDict.get("userData", {})})
|
||||
try:
|
||||
comp.CreateItem(playerId).SetEntityItem(
|
||||
serverApi.GetMinecraftEnum().ItemPosType.CARRIED,
|
||||
{"itemName": itemDict["newItemName"],
|
||||
"count": itemDict["count"],
|
||||
"auxValue": itemDict.get("newAuxValue", 0),
|
||||
"userData": itemDict.get("userData", {})})
|
||||
except Exception as e:
|
||||
print "[Shousi-consume] FAIL", e
|
||||
|
||||
# ============================================================================
|
||||
# 八、工具方法:替换方块(保留 aux, 兼容定向变体)
|
||||
|
||||
File renamed without changes.
+1
-1
@@ -536,7 +536,7 @@ FurnitureData+FurnitureService 实现, 注册到 FeatureDispatcher)
|
||||
- 热带鱼寿司(卷_4) -> 寿司堆(热带鱼_两个) -> 寿司堆(热带鱼_三个)
|
||||
[手持 热带鱼寿司(卷_4) 右键, 逐级堆叠, 每级消耗1个] [已实现]
|
||||
- 递减: 寿司堆(X_三个) -> 寿司堆(X_两个) -> 卷寿司 [空手右键, 逐级取走]
|
||||
机制: 每级取走一个并返还1个卷寿司; 鳕鱼/鲑鱼/热带鱼 同规则 [已实现]
|
||||
机制: 每级取走一个并以掉落物形式返还1个卷寿司; 鳕鱼/鲑鱼/热带鱼 同规则 [已实现]
|
||||
|
||||
七、盘装寿司组 (工作台合成)
|
||||
- 盘子 + 手握热带鱼寿司(三个) + 热带鱼寿司(卷_4) -> 盘装寿司(手握热带鱼三份+热带鱼寿司) (plate_27) [已实现]
|
||||
|
||||
@@ -190,6 +190,9 @@
|
||||
- 手握鲑鱼寿司(三个) -> 手握鲑鱼寿司(两个) -> 手握鲑鱼寿司(一个) ->空 [空手右键 吃] (txt 15)
|
||||
- 手握热带鱼寿司(三个) -> 手握热带鱼寿司(两个) -> 手握热带鱼寿司(一个) ->空 [空手右键 吃] (txt 16)
|
||||
- 手握鱿鱼寿司(三个) -> 手握鱿鱼寿司(两个) -> 手握鱿鱼寿司(一个) ->空 [空手右键 吃] (txt 17)
|
||||
- 盘装寿司 空手右键 吃: 盘装寿司(手握热带鱼三份+热带鱼寿司)(plate_27)、
|
||||
盘装寿司(手握鳕鱼三份+鳕鱼寿司)(plate_28)、盘装寿司(手握鲑鱼三份+鲑鱼寿司)(plate_29)、
|
||||
盘装寿司(手握鱿鱼三份+热带鱼寿司)(plate_42)
|
||||
- 未做原因: 均为"空手右键 吃"的食用递减, 食用部分由统一的"总食用功能"汇总实现,
|
||||
本次不实现 (转化文档已用 todo 标注"吃的都 后续实现")
|
||||
|
||||
|
||||
Reference in new issue
Block a user