Skip to content

Commit f70053e

Browse files
fixed a bug where inhabitedTime of a chunk is 0 instead of a large value (thanks to sendingpackets)
1 parent 3a64d97 commit f70053e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ func exists(path string) bool {
7474
return false
7575
}
7676

77+
func Max(x int64, y int64) int64 {
78+
if x < y {
79+
return y
80+
}
81+
return x
82+
}
83+
7784
func process(dry bool, verbose bool, perChunkMode bool, path string, newPath string, minTime int64) (err error) {
7885
moveRegions := len(newPath) != 0
7986

@@ -127,7 +134,13 @@ regionLoop:
127134

128135
xPos := chunk.XPos + chunk.Level.XPos
129136
zPos := chunk.ZPos + chunk.Level.ZPos
130-
inhabitedTime := chunk.InhabitedTime + chunk.Level.InhabitedTime
137+
inhabitedTime := Max(chunk.InhabitedTime, chunk.Level.InhabitedTime)
138+
139+
if inhabitedTime <= 0 {
140+
log.Println("Skipping", file, "because of an invalid or unreadable chunk at x:", xPos, "z:", zPos, "InhabitedTime =", inhabitedTime)
141+
continue regionLoop
142+
}
143+
131144
if perChunkMode {
132145
if inhabitedTime > minTime {
133146
if verbose {

0 commit comments

Comments
 (0)