Thank you for explaining it, the collision works perfectly now.
Also, is there any way to make this work when it reaches the negatives? I just tried it by making it absolute, but I knew that wouldn't work because the number line is reversed, but the chunks have their independent grids, so they aren't affected. So I end up with seemingly random collisions. Any ideas?
When x is negative, x%320 will be negative too. Because of this, when -320 < x < 320, chunkX = 0, so this chunk is 640 blocks wide. Is it intentional?
No, this is not intentional, but I also haven't had any problems with it yet.