修改菜谱 2
This commit is contained in:
1 parent
11e9780dd4
commit
8372b14dbd
3 files changed
+5
-35
No files matched your search
@@ -722,10 +722,9 @@ BLOCK_SWITCHES = [
|
||||
"type": "switch",
|
||||
"giveItem": "minecraft:water_bucket",
|
||||
},
|
||||
# ---- 放脏盘子 ----
|
||||
# 【放第一个脏盘子】水槽_0 → 水槽_2
|
||||
# 【放第一个脏盘子 有水放盘子】水槽_1 → 水槽_2
|
||||
{
|
||||
"source": "rtdd:flume_0",
|
||||
"source": "rtdd:flume_1",
|
||||
"item": "rtdd:plate_0a",
|
||||
"target": "rtdd:flume_2",
|
||||
"consume": 1,
|
||||
|
||||
+2
-30
@@ -429,27 +429,12 @@ class BlockSwitchService(BlueFoxServerSystem):
|
||||
"""
|
||||
try:
|
||||
blockData = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
print "[BlockSwitchService] _writeBlockData GetBlockEntityData returned: %s (pos=%s dim=%s)" % (type(blockData).__name__ if blockData is not None else "None", pos, dim)
|
||||
if blockData is None:
|
||||
print "[BlockSwitchService] _writeBlockData blockData is None: pos=%s dim=%s" % (pos, dim)
|
||||
return
|
||||
for key, value in kwargs.items():
|
||||
print "[BlockSwitchService] _writeBlockData setting: [%s]=%s (type=%s)" % (key, value, type(value).__name__)
|
||||
blockData[key] = value
|
||||
# 写入后立即读取验证
|
||||
verifyData = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if verifyData:
|
||||
for key in kwargs:
|
||||
try:
|
||||
val = verifyData[key]
|
||||
print "[BlockSwitchService] _writeBlockData verify: [%s]=%s" % (key, val)
|
||||
except:
|
||||
print "[BlockSwitchService] _writeBlockData verify: [%s]=<KEY_ERROR>" % key
|
||||
else:
|
||||
print "[BlockSwitchService] _writeBlockData verify FAILED: blockData is None after write!"
|
||||
except Exception as e:
|
||||
import traceback
|
||||
print "[BlockSwitchService] _writeBlockData 写入失败: pos=%s dim=%s err=%s trace=%s" % (pos, dim, str(e), traceback.format_exc())
|
||||
pass
|
||||
|
||||
def _saveRecord(self, key, playerId, pos, dim, record):
|
||||
"""
|
||||
@@ -489,7 +474,6 @@ class BlockSwitchService(BlueFoxServerSystem):
|
||||
记录存在方块实体数据里,所以玩家退出游戏再重进,
|
||||
loadSwitchRecord 还能从方块里把物品读回来。
|
||||
"""
|
||||
print "[BlockSwitchService] saveSwitchRecord pos=%s dim=%s record=%s" % (pos, dim, record)
|
||||
if "count" in record:
|
||||
self._writeBlockData(dim, pos,
|
||||
rtdd_swt="count",
|
||||
@@ -511,14 +495,9 @@ class BlockSwitchService(BlueFoxServerSystem):
|
||||
"""
|
||||
try:
|
||||
blockData = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
print "[BlockSwitchService] loadSwitchRecord GetBlockEntityData returned: %s (pos=%s dim=%s)" % (type(blockData).__name__ if blockData is not None else "None", pos, dim)
|
||||
if blockData is None:
|
||||
print "[BlockSwitchService] loadSwitchRecord blockData is None!"
|
||||
return None
|
||||
# 注意:BlockEntityData 对象不支持 .keys() 和 .get() 方法
|
||||
# 只支持 [] 操作符(__getitem__),key 不存在会抛 KeyError
|
||||
swt = blockData["rtdd_swt"] # 记录类型:"count" 或 "stack"
|
||||
print "[BlockSwitchService] loadSwitchRecord rtdd_swt=%s" % swt
|
||||
swt = blockData["rtdd_swt"]
|
||||
if swt == "count":
|
||||
count = blockData["rtdd_swc"]
|
||||
itemName = blockData["rtdd_swi"]
|
||||
@@ -526,7 +505,6 @@ class BlockSwitchService(BlueFoxServerSystem):
|
||||
auxValue = blockData["rtdd_swa"]
|
||||
except (KeyError, Exception):
|
||||
auxValue = 0
|
||||
print "[BlockSwitchService] loadSwitchRecord count data: count=%s itemName=%s auxValue=%s" % (count, itemName, auxValue)
|
||||
return {
|
||||
"count": count,
|
||||
"itemName": itemName,
|
||||
@@ -534,16 +512,12 @@ class BlockSwitchService(BlueFoxServerSystem):
|
||||
}
|
||||
elif swt == "stack":
|
||||
stack = blockData["rtdd_sws"]
|
||||
print "[BlockSwitchService] loadSwitchRecord stack data: len=%s" % len(stack)
|
||||
return {
|
||||
"stack": stack,
|
||||
}
|
||||
else:
|
||||
print "[BlockSwitchService] loadSwitchRecord unknown swt: %s" % swt
|
||||
return None
|
||||
except Exception as e:
|
||||
import traceback
|
||||
print "[BlockSwitchService] loadSwitchRecord exception: %s trace=%s" % (str(e), traceback.format_exc())
|
||||
return None
|
||||
|
||||
def clearSwitchRecord(self, key, playerId, pos, dim):
|
||||
@@ -676,7 +650,6 @@ class BlockSwitchService(BlueFoxServerSystem):
|
||||
|
||||
先更新内存,再延迟写入方块实体。
|
||||
"""
|
||||
print "[BlockSwitchService] _saveRecordDelayed key=%s record=%s" % (key, record)
|
||||
self.switchRecord[key] = record
|
||||
gameComp.AddTimer(0.1, self.saveSwitchRecord, playerId, pos, dim, record)
|
||||
|
||||
@@ -684,7 +657,6 @@ class BlockSwitchService(BlueFoxServerSystem):
|
||||
"""
|
||||
延迟一帧清除方块实体数据。
|
||||
"""
|
||||
print "[BlockSwitchService] _clearRecordDelayed key=%s" % (key,)
|
||||
self.switchRecord.pop(key, None)
|
||||
gameComp.AddTimer(0.1, self._clearRecordWrite, playerId, pos, dim)
|
||||
|
||||
|
||||
@@ -652,12 +652,11 @@ class CookingService(BlueFoxServerSystem):
|
||||
try:
|
||||
blockData = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if blockData is None:
|
||||
print "[CookingService] _writeBlockData blockData is None: pos=%s dim=%s" % (pos, dim)
|
||||
return
|
||||
for key, value in kwargs.items():
|
||||
blockData[key] = value
|
||||
except Exception as e:
|
||||
print "[CookingService] _writeBlockData 写入失败: pos=%s dim=%s err=%s" % (pos, dim, str(e))
|
||||
pass
|
||||
|
||||
# ============================================================================
|
||||
# 统一数据加载入口(玩家右键方块时先把方块数据恢复到内存)
|
||||
|
||||
Reference in new issue
Block a user