Cubitect / cubiomes-viewer

An efficient graphical Minecraft seed finder and map viewer.
GNU General Public License v3.0
1.02k stars 60 forks source link

[Crash] Cubiomes can crash if user moves the map to the integer limit (2^31 at 1:1.5 zoom, 2^33 at 1:6 zoom, so on) #204

Closed Delvin4519 closed 1 year ago

Delvin4519 commented 1 year ago

This is somewhat related to # 203 where the map grid gets difficult to read at millions of blocks out.

As the title says, if a user moves the map to the positive or negative integer limit, cubiomes can crash and the program terminates.

The program should have some way to not load any tiles past the integer limit at the limit. This can be at the integer limit, or 1 map tile short of the integer limit.

The integer limit varies depending on the tile zoom. 1.18 and 1.19 need to zoom in twice for the same integer limit:

2^31 will crash cubiomes if zoomed in past 1:4 older than 1.17 or 1:2 newer than 1.18 2^33 will crash cubiomes if zoomed in past 1:16 older than 1.17 or 1:8 newer than 1.18 2^35 will crash cubiomes if zoomed in past 1:64 older than 1.17 or 1:32 newer than 1.18 2^37 will crash cubiomes if zoomed in past 1:256 older than 1.17 or 1:128 newer than 1.18 2^39 will crash cubiomes zoomed out.

The crash only occurs at the integer limit. For example, loading cubiomes at 2^32 (double the integer limit), doesn't crash the program.

It is possible for minecraft versions such as 1.12 to generate out to 2.147 billion blocks (2^31) without any negative side effects. Chunkbase and AMIDST render biome maps at 1:4 scale and, as such, can display tiles out to 8.58 billion blocks (2^33) without crashing or other negative effects.

Cubitect commented 1 year ago

I can just limit absolute coordinates to 30 million, which would have the side effect of visualizing the world border.

Delvin4519 commented 1 year ago

I guess a hard coded limit could work. In this case, it should be overridable up to the 2.1474836 billion limit.

Modern versions of Minecraft currently cannot exceed 2.1474836 billion, even if the world border at 30 million is removed from the game. Most historical artifacts at high distances have long been patched out. For the most part, Minecraft versions such as 1.12, as well as cubiomes, function normally even at 2.14 billion bocks. The Minecraft world, map and functions all work even at such high distances.

There’s also the case that some servers adjust the in game world border to varying sizes and moved locations, such as 10,000 or 8000 blocks from spawn, or the center of the world border isn’t at 0,0. The world border at 30 million blocks is configurable, and can be shifted locations, removed, shrunk, deceased, offset, or increased. Creative mode players can change the world border on the fly anytime in game.

Cubitect commented 1 year ago

There needs to be some leeway to allow math without causing integer overflow, because catching integer overflow everywhere it could occur is not very practical. Limiting the range is easier.

The world border is clamped to 30 million, which effectively makes it a fixed limit to the world size, not just an administrative tool.

Delvin4519 commented 1 year ago

As of v3.1, map tiles no longer terminates the program, the biome label tooltip can stil terminate the program on the negative coordinates side, it seems.

The biome label tooltip probably needs to be clamped to be within the integer limit, to avoid having the tooltip label overflow.

Also one other note, historical minecraft versions such as Beta 1.7.3 either did not have, or used different hard-coded borders than modern versions, the default border was only introduced in version 1.8.

Delvin4519 commented 1 year ago

Resolved as of v3.1.1 (at least from what I can tell from testing), marking as resolved and closed.