MCIndevLevel: unpacked BlockLight array from Data array.
xxx move to unpackChunkData and get full indev editing working, but nobody can play indev right now
This commit is contained in:
parent
9f8a1ab35a
commit
519ff19908
48
mclevel.py
48
mclevel.py
@ -2605,18 +2605,17 @@ class MCIndevLevel(MCLevel):
|
|||||||
def setBlockDataAt(self, x,y,z, newdata):
|
def setBlockDataAt(self, x,y,z, newdata):
|
||||||
if x<0 or y<0 or z<0: return 0
|
if x<0 or y<0 or z<0: return 0
|
||||||
if x>=self.Width or y>=self.Height or z>=self.Length: return 0;
|
if x>=self.Width or y>=self.Height or z>=self.Length: return 0;
|
||||||
self.Data[x,z,y] &= 0xf0
|
self.Data[x,z,y] = (newdata & 0xf);
|
||||||
self.Data[x,z,y] |= (newdata & 0xf);
|
|
||||||
|
|
||||||
def blockDataAt(self, x, y, z):
|
def blockDataAt(self, x, y, z):
|
||||||
if x<0 or y<0 or z<0: return 0
|
if x<0 or y<0 or z<0: return 0
|
||||||
if x>=self.Width or y>=self.Height or z>=self.Length: return 0;
|
if x>=self.Width or y>=self.Height or z>=self.Length: return 0;
|
||||||
return self.Data[x,z,y] & 0xf;
|
return self.Data[x,z,y];
|
||||||
|
|
||||||
def blockLightAt(self, x, y, z):
|
def blockLightAt(self, x, y, z):
|
||||||
if x<0 or y<0 or z<0: return 0
|
if x<0 or y<0 or z<0: return 0
|
||||||
if x>=self.Width or y>=self.Height or z>=self.Length: return 0;
|
if x>=self.Width or y>=self.Height or z>=self.Length: return 0;
|
||||||
return (self.Data[x,z,y] & 0xf);
|
return self.BlockLight[x,z,y];
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "MCIndevLevel({0}): {1}W {2}L {3}H".format(self.filename, self.Width, self.Length, self.Height)
|
return "MCIndevLevel({0}): {1}W {2}L {3}H".format(self.filename, self.Width, self.Length, self.Height)
|
||||||
@ -2637,15 +2636,26 @@ class MCIndevLevel(MCLevel):
|
|||||||
self.Width = mapTag[Width].value
|
self.Width = mapTag[Width].value
|
||||||
self.Length = mapTag[Length].value
|
self.Length = mapTag[Length].value
|
||||||
self.Height = mapTag[Height].value
|
self.Height = mapTag[Height].value
|
||||||
self.Blocks = mapTag[Blocks].value
|
|
||||||
self.Blocks.shape = (self.Width, self.Length, self.Height, )
|
|
||||||
self.oldBlockStrides = self.Blocks.strides
|
|
||||||
self.Blocks.strides = (1, self.Width, self.Width * self.Length)
|
|
||||||
|
|
||||||
self.Data = mapTag[Data].value
|
mapTag[Blocks].value.shape = (self.Height, self.Length, self.Width)
|
||||||
self.Data.shape = (self.Width, self.Length, self.Height, )
|
|
||||||
self.oldDataStrides = self.Data.strides
|
self.Blocks = swapaxes(mapTag[Blocks].value, 0, 2)
|
||||||
self.Data.strides = (1, self.Width, self.Width * self.Length)
|
|
||||||
|
#self.Blocks.shape = (self.Width, self.Length, self.Height, )
|
||||||
|
#self.oldBlockStrides = self.Blocks.strides
|
||||||
|
#self.Blocks.strides = (1, self.Width, self.Width * self.Length)
|
||||||
|
|
||||||
|
mapTag[Data].value.shape = (self.Height, self.Length, self.Width)
|
||||||
|
|
||||||
|
self.Data = swapaxes(mapTag[Data].value, 0, 2)
|
||||||
|
|
||||||
|
self.BlockLight = self.Data & 0xf
|
||||||
|
|
||||||
|
self.Data >>= 4
|
||||||
|
|
||||||
|
#self.Data.shape = (self.Width, self.Length, self.Height, )
|
||||||
|
#self.oldDataStrides = self.Data.strides
|
||||||
|
#self.Data.strides = (1, self.Width, self.Width * self.Length)
|
||||||
|
|
||||||
self.Spawn = [mapTag[Spawn][i].value for i in range(3)];
|
self.Spawn = [mapTag[Spawn][i].value for i in range(3)];
|
||||||
|
|
||||||
@ -2706,13 +2716,11 @@ class MCIndevLevel(MCLevel):
|
|||||||
def saveToFile(self, filename = None):
|
def saveToFile(self, filename = None):
|
||||||
if filename == None: filename = self.filename;
|
if filename == None: filename = self.filename;
|
||||||
if filename == None:
|
if filename == None:
|
||||||
print "Attempted to save an unnamed schematic in place :x"
|
print "Attempted to save an unnamed file in place :x"
|
||||||
return; #you fool!
|
return; #you fool!
|
||||||
|
|
||||||
newBlockStrides = self.Blocks.strides;
|
self.Data <<= 4;
|
||||||
self.Blocks.strides = self.oldBlockStrides;
|
self.Data |= (self.BlockLight & 0xf)
|
||||||
newDataStrides = self.Data.strides;
|
|
||||||
self.Data.strides = self.oldDataStrides;
|
|
||||||
|
|
||||||
mapTag = nbt.TAG_Compound( name=Map );
|
mapTag = nbt.TAG_Compound( name=Map );
|
||||||
mapTag[Width] = nbt.TAG_Short(self.Width);
|
mapTag[Width] = nbt.TAG_Short(self.Width);
|
||||||
@ -2720,6 +2728,7 @@ class MCIndevLevel(MCLevel):
|
|||||||
mapTag[Length] = nbt.TAG_Short(self.Length);
|
mapTag[Length] = nbt.TAG_Short(self.Length);
|
||||||
mapTag[Blocks] = nbt.TAG_Byte_Array(self.Blocks);
|
mapTag[Blocks] = nbt.TAG_Byte_Array(self.Blocks);
|
||||||
mapTag[Data] = nbt.TAG_Byte_Array(self.Data);
|
mapTag[Data] = nbt.TAG_Byte_Array(self.Data);
|
||||||
|
|
||||||
mapTag[Spawn] = nbt.TAG_List([nbt.TAG_Short(i) for i in self.Spawn])
|
mapTag[Spawn] = nbt.TAG_List([nbt.TAG_Short(i) for i in self.Spawn])
|
||||||
|
|
||||||
self.root_tag[Map] = mapTag;
|
self.root_tag[Map] = mapTag;
|
||||||
@ -2741,8 +2750,9 @@ class MCIndevLevel(MCLevel):
|
|||||||
#print "Atomic Save: No old file to remove"
|
#print "Atomic Save: No old file to remove"
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.Blocks.strides = newBlockStrides;
|
self.BlockLight = self.Data & 0xf
|
||||||
self.Data.strides = newDataStrides;
|
|
||||||
|
self.Data >>= 4
|
||||||
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
Reference in New Issue
Block a user