初始化
This commit is contained in:
1 parent
dffebce01d
commit
ff618906d3
2501 files changed
+1181005
-21
No files matched your search
@@ -1,5 +1,6 @@
|
||||
# coding=utf-8
|
||||
import copy
|
||||
from ToolsConfig import *
|
||||
|
||||
MOD_NAME = 'rtdd'
|
||||
MOD_VERSION = '0.0.1'
|
||||
|
||||
+31
-19
@@ -1,4 +1,6 @@
|
||||
# coding=utf-8
|
||||
import copy
|
||||
|
||||
from ..ToolsConfig import *
|
||||
from BlueFoxSystem import BlueFoxServerSystem
|
||||
from ..OtherTools import Mount
|
||||
@@ -28,23 +30,27 @@ def GetLoadedBlockBlock():
|
||||
class BlockBlock(object):
|
||||
"""
|
||||
方块块,用于解决模型体积过大导致的模型消失的问题
|
||||
blockList = {
|
||||
(0, 0, 0): {'name': 'rtdd:carrotandbeef', 'aux': 0}
|
||||
(相对坐标位置): {'name': 方块ID, 'aux': 方块AUX}
|
||||
}
|
||||
"""
|
||||
blueFoxSystem = BlueFoxServerSystem if 0 else None
|
||||
blockList = {}
|
||||
|
||||
@classmethod
|
||||
def Load(cls, posDim):
|
||||
# type:(Tuple[int,int,int,int]) -> None
|
||||
"""
|
||||
通过维度坐标加载储存的块数据
|
||||
"""
|
||||
def getInstance(cls, posDim):
|
||||
instance = blockBlocks.get(posDim)
|
||||
if instance: return instance
|
||||
data = blockEntityDataComp.GetBlockEntityData(posDim[3], posDim[:3])
|
||||
if data and data['isCenter']:
|
||||
posDims = [tuple(_) for _ in data['posDims']]
|
||||
return cls(tuple(data['centerPosDim']), data['aux'], posDims)
|
||||
blockData = serverCompFactory.CreateBlockInfo(LevelId).GetBlockNew(posDim[:3], posDim[3])
|
||||
return cls(posDim, blockData['aux'])
|
||||
|
||||
def __init__(self, posDim, aux, posDims=None):
|
||||
# type:(Tuple[int,int,int,int],int,List[Tuple]) -> None
|
||||
# type:(Tuple,int,List[Tuple]) -> None
|
||||
self.blockPosDims = posDims # 方块块控制坐标
|
||||
self.centerPosDim = posDim # 控制中心
|
||||
self.aux = aux
|
||||
@@ -59,7 +65,7 @@ class BlockBlock(object):
|
||||
for posDim in self.blockPosDims:
|
||||
blockBlocks[posDim] = self
|
||||
|
||||
def ReplaceBlocks(self, newBlockList, otherData):
|
||||
def ReplaceBlocks(self, newBlockList, otherData=None, drop=0):
|
||||
"""
|
||||
替换方块,新方块依然具有方块实体的要求
|
||||
"""
|
||||
@@ -67,14 +73,10 @@ class BlockBlock(object):
|
||||
'posDims': self.blockPosDims,
|
||||
'aux': self.aux
|
||||
}
|
||||
if otherData is None: otherData = {}
|
||||
oldData.update(otherData)
|
||||
self.DestroyBlocks()
|
||||
self.DestroyBlocks(drop)
|
||||
self.CreateBlocks(newBlockList)
|
||||
self.ResetBlockData(oldData)
|
||||
|
||||
def ResetBlockData(self, data):
|
||||
for K_V in data.items():
|
||||
self.dataComp[K_V[0]] = K_V[1]
|
||||
|
||||
def DestroyFunction(self):
|
||||
"""
|
||||
@@ -83,20 +85,29 @@ class BlockBlock(object):
|
||||
for posDim in self.blockPosDims:
|
||||
del blockBlocks[posDim]
|
||||
|
||||
def Destroy(self):
|
||||
def Destroy(self, drop=0):
|
||||
"""
|
||||
销毁方块块
|
||||
:param drop:是否掉落核心方块
|
||||
"""
|
||||
self.DestroyFunction()
|
||||
self.DestroyBlocks()
|
||||
self.DestroyBlocks(drop)
|
||||
|
||||
def DestroyBlocks(self):
|
||||
def DestroyBlocks(self, drop=0):
|
||||
"""
|
||||
销毁方块块所控制的方块
|
||||
"""
|
||||
blockComp = serverCompFactory.CreateBlockInfo(LevelId)
|
||||
for posDim in self.blockPosDims:
|
||||
blockComp.SetBlockNew(posDim[:3], blockDict={'name': 'minecraft:air'}, dimensionId=posDim[3])
|
||||
posDim = copy.copy(self.blockPosDims)
|
||||
posDim.remove(self.centerPosDim)
|
||||
for posDim in posDim:
|
||||
blockComp.SetBlockNew(
|
||||
posDim[:3], blockDict={'name': 'minecraft:air'}, dimensionId=posDim[3]
|
||||
)
|
||||
blockComp.SetBlockNew(
|
||||
self.centerPosDim[:3], blockDict={'name': 'minecraft:air'}, dimensionId=self.centerPosDim[3],
|
||||
oldBlockHandling=1 if drop else 0
|
||||
)
|
||||
|
||||
def CreateBlocks(self, blockList=None):
|
||||
"""
|
||||
@@ -107,7 +118,6 @@ class BlockBlock(object):
|
||||
blockComp = serverCompFactory.CreateBlockInfo(LevelId)
|
||||
for pos in self.blockList:
|
||||
blockInfo = blockList[pos]
|
||||
blockInfo['aux'] = self.aux
|
||||
posDim = self.CalculatePosDimFromOffset(pos, self.centerPosDim, self.aux)
|
||||
blockComp.SetBlockNew(posDim[:3], blockDict=blockInfo, dimensionId=posDim[3])
|
||||
dataComp = blockEntityDataComp.GetBlockEntityData(posDim[3], posDim[:3])
|
||||
@@ -128,6 +138,7 @@ class BlockBlock(object):
|
||||
|
||||
@classmethod
|
||||
def CreatePosDims(cls, posDim, aux):
|
||||
# type:(Tuple,int) -> List[Tuple]
|
||||
"""
|
||||
创建方块块控制坐标
|
||||
"""
|
||||
@@ -135,6 +146,7 @@ class BlockBlock(object):
|
||||
|
||||
@classmethod
|
||||
def CalculatePosDimFromOffset(cls, offset, posDim, aux):
|
||||
"""计算偏移坐标维度"""
|
||||
originCoord = OriginCoord(posDim)
|
||||
_, __, ___ = FixPosition(originCoord.AbsPos(
|
||||
RotCoord(BlockFaceRot[aux], RotAxes.Y).CalculatePos(offset)
|
||||
|
||||
Reference in new issue
Block a user