Esempio n. 1
0
 def _saveTileEntities(self, db):
   data = nbt.DataWriter()
   for subchunk in self.subchunks:
     if subchunk is None:
       continue
     for x in range(16):
       for y in range(16):
         for z in range(16):
           block = subchunk.getBlock(x, y, z)
           if block.nbt is not None: # Add back the correct position.
             block.nbt.add(nbt.TAG_Int("x", subchunk.x * 16 + x))
             block.nbt.add(nbt.TAG_Int("y", subchunk.y * 16 + y))
             block.nbt.add(nbt.TAG_Int("z", subchunk.z * 16 + z))
             nbt.encode(block.nbt, data)
   ldb.put(db, self.keyBase + b"1", data.get())
Esempio n. 2
0
  def save(self, db, force=False):
    if self.dirty or force:
      data = struct.pack("<BB", self.version, 1)
      for i in range(len(self.blocks)):
        palette, blockIDs = self._savePalette(i)
        data += self._saveBlocks(len(palette), blockIDs)
        data += struct.pack("<I", len(palette))
        for block in palette:
          data += nbt.encode(block)

      key = struct.pack("<iicB", self.x, self.z, b'/', self.y)
      ldb.put(db, key, data)
Esempio n. 3
0
 def _saveEntities(self, db):
   data = nbt.DataWriter()
   for entity in self.entities:
     nbt.encode(entity, data)
   ldb.put(db, self.keyBase + b"2", data.get())