max-mapper / minecraft-region

parses chunks out of a minecraft region file
18 stars 6 forks source link

Mod that handles negatives #1

Closed shama closed 11 years ago

shama commented 11 years ago

Found the issue with negative region coordinates in blockplot:

function mod (num, n) { return ( num < 0 ? (num % n) + n : num % n) }
console.log(mod(-32, 32)); // === 32

function mod (num, n) { return ((num % n) + n) % n }
console.log(mod2(-32, 32)); // === 0

So r.0.-1.mca would start counting at 32 and be instantly out of range.

max-mapper commented 11 years ago

nice, lesson learned... which is that I shouldn't change code I dont understand :D https://github.com/maxogden/minecraft-region/commit/62d7f830dc74e7c9a4d4095ca5d28ee780896438