def getBlock(self,x,y,z): pos = (y & 0x0F) + (z << 4 ) + (x << 8) posY = y >> 4 #On teste si la section existe blockIds = self.blockIds.get(posY) blockDatas = self.blockDatas.get(posY) blockAddBlocks = self.blockAddBlocks.get(posY) if blockIds is None: block = MCImportBlock() block.setId(0) return block #On recupere les information du block blockAddBlock = 0 if not blockAddBlocks is None: if pos & 1: blockAddBlock = (blockAddBlocks[pos >> 1] >> 4) & 0x0F else: blockData = (blockAddBlocks[pos >> 1]) & 0x0F blockId = blockIds[pos] + (blockAddBlock << 8) blockData = 0 if pos & 1: blockData = (blockDatas[pos >> 1] >> 4) & 0x0F else: blockData = (blockDatas[pos >> 1]) & 0x0F #On genere le bloc block = MCImportBlock() block.setId(blockId) block.setData(blockData) return block
def getBlock(self,x,y,z): pos = x * 16 * 128 + z * 128 + y #Offset de l'id du bloc dans le tableau dpos = pos >> 1 #Offset des metadata du bloc s = pos & 1 #4 bit superieur ou inferieur #Creation du bloc block = MCImportBlock() blockID = self.blockIds[pos] block.setId(blockID) #Preparation des metadata if(s == 0): block.setData(self.blockDatas[dpos] & 0x0F) else: block.setData((self.blockDatas[dpos] >> 4) & 0x0F) return block
def removeBlock(self,x,y,z): AIR_BLOCK = MCImportBlock() AIR_BLOCK.setId(0) AIR_BLOCK.setData(0) self.setBlock(x, y, z, AIR_BLOCK) return