如果玩家背包有这个成品菜,优先给这个数量加一,也就是把取到的成品菜放到同类项,次优先则:当我们主手没有物品时,获取到玩家主手上去,再次级,则是玩家主手有东西,背包有空余位置,那么将成品菜放到玩家背包里去,最次就是玩家背包满了,主手也有东西,那么就以现在我们这样的掉落物形式获得

This commit is contained in:
wenhe committed 2026-09-29 12:12:32 +08:00
1 parent 36af4e3c59
commit 14de700929
6 files changed
+73 -10

No files matched your search

@@ -271,7 +271,7 @@ class ChaoguoService(BlueFoxServerSystem):
elif action == "take_out":
# 出锅: 锅变回 炒锅(空) + 掉落盘装成品(掉落物形式)
self.replaceBlock(pos, dim, WOK, playerId)
self.dropItem(dim, pos, recipe["dropItem"])
self.dropItem(dim, pos, recipe["dropItem"], playerId=playerId)
self._clearWokData(dim, pos)
# 普通替换方块(盖锅/锅底/放料/加料)
# 注意: 翻炒(stir)的 target 由 _handleStir 满4次才替换, 这里必须排除,
@@ -400,9 +400,28 @@ class ChaoguoService(BlueFoxServerSystem):
# 七、工具方法,以掉落物形式生成物品
# ============================================================================
def dropItem(self, dim, pos, itemName, count=1, aux=0):
def dropItem(self, dim, pos, itemName, count=1, aux=0, playerId=None):
"""取成品/返容器: playerId 给出时【优先入包】—— 主手空->放主手;
否则入背包(同类叠加/空位); 背包满(返回False)->落回地面掉落物。
不传 playerId(无玩家上下文, 如破坏掉落) 保持原掉落物, 零影响。"""
try:
itemDict = {"itemName": itemName, "count": count, "auxValue": aux}
if playerId is not None:
# 1) 主手空 -> 放主手
cur = self.getCarriedItem(playerId)
handItem = (cur or {}).get("newItemName")
if not handItem or handItem == "minecraft:air":
try:
if comp.CreateItem(playerId).SpawnItemToPlayerCarried(itemDict, playerId):
return
except Exception:
pass
# 2) 否则入包(同类叠加/空位); 失败(满)->掉落
try:
if comp.CreateItem(playerId).SpawnItemToPlayerInv(itemDict, playerId):
return
except Exception:
pass
self.CreateEngineItemEntity(itemDict, dim, (pos[0], pos[1] + 0.5, pos[2]))
except Exception:
pass
@@ -301,14 +301,14 @@ class TangguoService(BlueFoxServerSystem):
action = recipe.get("action")
if action == "take_out":
self.replaceBlock(pos, dim, recipe.get("target") or self._defaultPot(), playerId)
self.dropItem(dim, pos, recipe["dropItem"], recipe.get("count", 1))
self.dropItem(dim, pos, recipe["dropItem"], recipe.get("count", 1), playerId=playerId)
# 普通替换方块(加水/盖锅/下汤底/组合/加料/汤面)
if recipe.get("target") and action != "take_out":
self.replaceBlock(pos, dim, recipe["target"], playerId)
# 额外掉落(倒水掉水桶 / 蔬菜乱炖掉汤锅(空) / 汤面掉木碗)
if recipe.get("drop"):
self.dropItem(dim, pos, recipe["drop"])
self.dropItem(dim, pos, recipe["drop"], playerId=playerId)
# 加料后启动计时(记录发起玩家); 下方无点燃炉灶时提示
if recipe.get("startTimer"):
@@ -375,9 +375,28 @@ class TangguoService(BlueFoxServerSystem):
# 六、工具方法,以掉落物形式生成物品
# ============================================================================
def dropItem(self, dim, pos, itemName, count=1, aux=0):
def dropItem(self, dim, pos, itemName, count=1, aux=0, playerId=None):
"""取成品/返容器: playerId 给出时【优先入包】—— 主手空->放主手;
否则入背包(同类叠加/空位); 背包满(返回False)->落回地面掉落物。
不传 playerId(无玩家上下文, 如破坏掉落) 保持原掉落物, 零影响。"""
try:
itemDict = {"itemName": itemName, "count": count, "auxValue": aux}
if playerId is not None:
# 1) 主手空 -> 放主手
cur = self.getCarriedItem(playerId)
handItem = (cur or {}).get("newItemName")
if not handItem or handItem == "minecraft:air":
try:
if comp.CreateItem(playerId).SpawnItemToPlayerCarried(itemDict, playerId):
return
except Exception:
pass
# 2) 否则入包(同类叠加/空位); 失败(满)->掉落
try:
if comp.CreateItem(playerId).SpawnItemToPlayerInv(itemDict, playerId):
return
except Exception:
pass
self.CreateEngineItemEntity(itemDict, dim, (pos[0], pos[1] + 0.5, pos[2]))
except Exception:
pass
@@ -267,7 +267,7 @@ class YouguoService(BlueFoxServerSystem):
action = recipe.get("action")
if action == "take_out":
self.replaceBlock(pos, dim, OILPOT_1, playerId)
self.dropItem(dim, pos, recipe["dropItem"])
self.dropItem(dim, pos, recipe["dropItem"], playerId=playerId)
# 替换方块(倒油/取油/放料)
if recipe.get("target"):
self.replaceBlock(pos, dim, recipe["target"], playerId)
@@ -340,9 +340,28 @@ class YouguoService(BlueFoxServerSystem):
# 七、工具方法,以掉落物形式生成物品
# ============================================================================
def dropItem(self, dim, pos, itemName, count=1, aux=0):
def dropItem(self, dim, pos, itemName, count=1, aux=0, playerId=None):
"""取成品/返容器: playerId 给出时【优先入包】—— 主手空->放主手;
否则入背包(同类叠加/空位); 背包满(返回False)->落回地面掉落物。
不传 playerId(无玩家上下文, 如破坏掉落) 保持原掉落物, 零影响。"""
try:
itemDict = {"itemName": itemName, "count": count, "auxValue": aux}
if playerId is not None:
# 1) 主手空 -> 放主手
cur = self.getCarriedItem(playerId)
handItem = (cur or {}).get("newItemName")
if not handItem or handItem == "minecraft:air":
try:
if comp.CreateItem(playerId).SpawnItemToPlayerCarried(itemDict, playerId):
return
except Exception:
pass
# 2) 否则入包(同类叠加/空位); 失败(满)->掉落
try:
if comp.CreateItem(playerId).SpawnItemToPlayerInv(itemDict, playerId):
return
except Exception:
pass
self.CreateEngineItemEntity(itemDict, dim, (pos[0], pos[1] + 0.5, pos[2]))
except Exception:
pass
@@ -3,7 +3,7 @@
"minecraft:recipe_shaped": {
"key": {
"0": {
"tag": "minecraft:wooden_trapdoors",
"item": "minecraft:spruce_trapdoor",
"data": 0
},
"3": {
+6
View File
@@ -721,6 +721,12 @@ FurnitureData+FurnitureService 实现, 注册到 FeatureDispatcher)
(同汤锅): 客户端 ClientItemUseOnEvent ret=True 消闪 + NotifyToServer('TakeoutRequest')
-> YouguoService.handleTakeoutRequest(校验落点仍是成品防重复). 由 InterceptData.TAKEOUT_CANCEL
自动派生 [已实现]
【成品入包 2026-09-29】炒锅/汤锅/油锅的 dropItem 工具方法统一改为【优先入包】(用户要求):
传 playerId 时 —— ①主手空->放主手(SpawnItemToPlayerCarried) ②否则入背包
(SpawnItemToPlayerInv, 引擎自动同类叠加/找空位) ③背包满(返回False)->落回地面掉落物。
三处取成品调用点(炒锅出锅/油锅出锅/汤锅盛出+返容器的 桶/锅/木碗) 均补传 playerId,
玩家不再需要弯腰捡, 直接进手/进包; 不传 playerId 的其他 dropItem 调用(如破坏掉落)
保持原掉落物, 零影响 [已实现]
【留后】各盘装成品 右键吃(总食用功能后续实现)、天妇罗炸虾递减吃(整份->半份 plate_49a)、
盘子用后变脏
+2 -2
View File
@@ -303,10 +303,10 @@ todo 补充
(3 石砖竖排 -> 1 烟道)
· 吧台 b_111 / todo 自己想一个
【设计】吧台(b_111)【有序】
【空】 【空】 原版任意活板门
【空】 【空】 云杉活板门
木条 木条 木条
任意原版木板 任意原版木板 任意原版木板
(3 木条 + 3 木板 -> 1 吧台)
(3 木条 + 3 木板 + 1 云杉活板门 -> 1 吧台)
· 台柜 b_112 —— 无配方todo 自己想一个
【设计】台柜(b_112)【有序】
任意原版木板 任意原版木板 任意原版木板