CubicChunks

CubicChunks

840k Downloads

Integer Overflow at Coords

ThisTestUser opened this issue ยท 2 comments

commented

Right now, the midPos function at Coords.java (https://github.com/OpenCubicChunks/CubicChunks/blob/MC_1.12/src/api/java/io/github/opencubicchunks/cubicchunks/api/util/Coords.java#L49) simply adds up the coordinates, risking an overflow. A better way to do this is to first cast the coordinates to a long and then bitshift.

commented

Generally right, but as of now, coordinates should be limited to a max of 2^30 or so, effectively eliminating this problem since int max is 2^31 -1. But if the limit should ever be changed to a higher value this will have to be kept in mind.

commented

This is effectively the only error that stops the terrain from working. If this bug is patched, there is no issue with going up to a couple thousand blocks behind the integer limit.
And by the way, here's a gallery of what you could see beyond 2^30: https://www.reddit.com/r/Minecraft/comments/eiogro/1122_the_sky_vertex_far_lands/