Skip to content
Browse files

Added: RegionFile now touches the chunk's timestamp field whenever a …

…chunk is saved.
  • Loading branch information...
1 parent ef4c1f4 commit c60c3f25edce4756a672292d36612ce4ce9c5fd1 @codewarrior0 codewarrior0 committed
Showing with 19 additions and 0 deletions.
  1. +19 −0 regionfile.py
View
19 regionfile.py
@@ -4,6 +4,7 @@
import zlib
from numpy import fromstring
+import time
from mclevelbase import notclosing, RegionMalformed, ChunkNotPresent
import nbt
@@ -287,6 +288,8 @@ def _saveChunk(self, cx, cz, data, format):
self.setOffset(cx, cz, sectorNumber << 8 | sectorsNeeded)
self.writeSector(sectorNumber, data, format)
+ self.setTimestamp(cx, cz)
+
def writeSector(self, sectorNumber, data, format):
with self.file as f:
log.debug("REGION: Writing sector {0}".format(sectorNumber))
@@ -313,6 +316,22 @@ def setOffset(self, cx, cz, offset):
f.seek(0)
f.write(self.offsets.tostring())
+ def getTimestamp(self, cx, cz):
+ cx &= 0x1f
+ cz &= 0x1f
+ return self.modTimes[cx + cz * 32]
+
+ def setTimestamp(self, cx, cz, timestamp = None):
+ if timestamp is None:
+ timestamp = time.time()
+
+ cx &= 0x1f
+ cz &= 0x1f
+ self.modTimes[cx + cz * 32] = timestamp
+ with self.file as f:
+ f.seek(self.SECTOR_BYTES)
+ f.write(self.modTimes.tostring())
+
SECTOR_BYTES = 4096
SECTOR_INTS = SECTOR_BYTES / 4
CHUNK_HEADER_SIZE = 5

0 comments on commit c60c3f2

Please sign in to comment.
Something went wrong with that request. Please try again.