方块转换数据库 ceshi2
This commit is contained in:
1 parent
a9099b6044
commit
3c90a1c613
1 file changed
+19
-3
@@ -369,6 +369,10 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
if recipe.get("target"):
|
if recipe.get("target"):
|
||||||
self.replaceBlock(pos, dim, recipe["target"], playerId)
|
self.replaceBlock(pos, dim, recipe["target"], playerId)
|
||||||
|
|
||||||
|
# 如果配方指定了给物品(如烧烤架浇水给桶)
|
||||||
|
if recipe.get("giveItem"):
|
||||||
|
self.giveItem(playerId, recipe["giveItem"])
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# ---- 逆向操作:从方块里取东西(空手右键或取回物品) ----
|
# ---- 逆向操作:从方块里取东西(空手右键或取回物品) ----
|
||||||
@@ -399,6 +403,10 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
else:
|
else:
|
||||||
self.switchRecord[key] = record
|
self.switchRecord[key] = record
|
||||||
|
|
||||||
|
# 如果配方直接指定了给什么物品(水槽、盘子架取回、挂肉钩退回等)
|
||||||
|
if recipe.get("giveItem"):
|
||||||
|
self.giveItem(playerId, recipe["giveItem"])
|
||||||
|
|
||||||
# 替换方块
|
# 替换方块
|
||||||
if recipe.get("target"):
|
if recipe.get("target"):
|
||||||
self.replaceBlock(pos, dim, recipe["target"], playerId)
|
self.replaceBlock(pos, dim, recipe["target"], playerId)
|
||||||
@@ -613,7 +621,7 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
# 工具方法:替换方块
|
# 工具方法:替换方块
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
def replaceBlock(self, pos, dim, newBlockName, playerId):
|
def replaceBlock(self, pos, dim, newBlockName, playerId, aux=None):
|
||||||
"""
|
"""
|
||||||
把指定位置的方块替换成新方块。
|
把指定位置的方块替换成新方块。
|
||||||
|
|
||||||
@@ -622,15 +630,23 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
dim: 维度ID
|
dim: 维度ID
|
||||||
newBlockName: 新方块的完整ID,如 "rtdd:oilpan"
|
newBlockName: 新方块的完整ID,如 "rtdd:oilpan"
|
||||||
playerId: 玩家ID(用于创建组件)
|
playerId: 玩家ID(用于创建组件)
|
||||||
|
aux: 方块附加值(朝向)。None=自动继承旧方块的朝向,数字=强制指定
|
||||||
|
|
||||||
对照 BlockBlock.py 的标准写法:
|
对照 BlockBlock.py 的标准写法:
|
||||||
- 使用命名参数
|
- 使用命名参数
|
||||||
- oldBlockHandling=0 表示直接替换(不保留旧方块数据)
|
- oldBlockHandling=0 表示直接替换(不保留旧方块数据)
|
||||||
- aux=0 表示默认附加值
|
- aux 默认继承旧方块朝向,这样替换后不会转方向
|
||||||
"""
|
"""
|
||||||
|
# 如果没指定 aux,自动读取旧方块的朝向并继承
|
||||||
|
if aux is None:
|
||||||
|
try:
|
||||||
|
oldBlock = comp.CreateBlockInfo(playerId).GetBlockNew(pos, dim)
|
||||||
|
aux = oldBlock.get("aux", 0)
|
||||||
|
except:
|
||||||
|
aux = 0
|
||||||
comp.CreateBlockInfo(playerId).SetBlockNew(
|
comp.CreateBlockInfo(playerId).SetBlockNew(
|
||||||
pos,
|
pos,
|
||||||
blockDict={"name": newBlockName, "aux": 0},
|
blockDict={"name": newBlockName, "aux": aux},
|
||||||
oldBlockHandling=0,
|
oldBlockHandling=0,
|
||||||
dimensionId=dim)
|
dimensionId=dim)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user