From dbe3d388c01304c3e54d79011c60849d2c3a3371 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Sat, 18 Nov 2023 10:42:45 +0100 Subject: [PATCH] fix min/max chunk calc --- process_export_protected.go | 13 +++++++++++++ util.go | 12 +++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/process_export_protected.go b/process_export_protected.go index 7b7a0bb..dd5ab64 100644 --- a/process_export_protected.go +++ b/process_export_protected.go @@ -54,6 +54,19 @@ func ProcessExportProtected(areas []*areasparser.Area) error { chunk1_x, chunk1_y, chunk1_z := GetChunkPosFromNode(p1.X, p1.Y, p1.Z) chunk2_x, chunk2_y, chunk2_z := GetChunkPosFromNode(p2.X, p2.Y, p2.Z) + logrus.WithFields(logrus.Fields{ + "chunk1_x": chunk1_x, + "chunk1_y": chunk1_y, + "chunk1_z": chunk1_z, + "chunk2_x": chunk2_x, + "chunk2_y": chunk2_y, + "chunk2_z": chunk2_z, + "p1": p1, + "p2": p2, + "area.Pos1": area.Pos1, + "area.Pos2": area.Pos2, + }).Info("exported area info") + for x := chunk1_x; x <= chunk2_x; x++ { for y := chunk1_y; y <= chunk2_y; y++ { for z := chunk1_z; z <= chunk2_z; z++ { diff --git a/util.go b/util.go index fd6472a..3d29134 100644 --- a/util.go +++ b/util.go @@ -39,20 +39,26 @@ func SortPos(p1, p2 *areasparser.GenericPos) (*areasparser.GenericPos, *areaspar if p1.X > p2.X { hi.X = p1.X - } else { lo.X = p2.X + } else { + hi.X = p2.X + lo.X = p1.X } if p1.Y > p2.Y { hi.Y = p1.Y - } else { lo.Y = p2.Y + } else { + hi.Y = p2.Y + lo.Y = p1.Y } if p1.Z > p2.Z { hi.Z = p1.Z - } else { lo.Z = p2.Z + } else { + hi.Z = p2.Z + lo.Z = p1.Z } return lo, hi