Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D view crash if map contains biome ID 255 (with fix) #416

Open
Alzurana opened this issue Jul 23, 2024 · 0 comments
Open

3D view crash if map contains biome ID 255 (with fix) #416

Alzurana opened this issue Jul 23, 2024 · 0 comments

Comments

@Alzurana
Copy link

Alzurana commented Jul 23, 2024

Hello there. Found a bug in 3D view that might also be related to another issue that's not listed here

What:
When importing a map (from an MC world, 1.12.2) with a biome ID 255 in it and then opening 3D view a crash occurs with the following call stack.
java.lang.ArrayIndexOutOfBoundsException: Index 255 out of bounds for length 255 at org.pepsoft.worldpainter.layers.renderers.BiomeRenderer.<init>(BiomeRenderer.java:35) at org.pepsoft.worldpainter.TileRenderer.<init>(TileRenderer.java:40) at org.pepsoft.worldpainter.threedeeview.Tile3DRenderer.<init>(Tile3DRenderer.java:42) at org.pepsoft.worldpainter.threedeeview.Background3DTileRenderer.<init>(Background3DTileRenderer.java:28) at org.pepsoft.worldpainter.threedeeview.ThreeDeeRenderManager.startThreads(ThreeDeeRenderManager.java:95) at org.pepsoft.worldpainter.threedeeview.ThreeDeeRenderManager.renderTile(ThreeDeeRenderManager.java:38) at java.lang.Iterable.forEach(Iterable.java:75) at org.pepsoft.worldpainter.threedeeview.ThreeDeeView.actionPerformed(ThreeDeeView.java:358) at javax.swing.Timer.fireActionPerformed(Timer.java:311) at javax.swing.Timer$DoPostEvent.run(Timer.java:243)

Possibly related issue:
The same map also does not render any layers or preview in the center view. All I see is the biomes that would create based on the seed of this world but not the world itself. However, the bottom info bar clearly shows that elevation, slope, terrain and biome data was loaded and it is being displayed in text in the bottom row. Just the rendering seems to glitch out. This is what prompted me to click on 3D view in the first place.

How to fix:
This file: WorldPainter/WPCore/src/main/java/org/pepsoft/worldpainter/layers/renderers/BiomeRenderer.java
image
Array "patterns" is initialized with 255 elements, meaning it's index will range from 0 to 254.
At line 35 a biome ID is used as an index in said array, biome ID's can go up to 255 (possible values of a byte 0-255, 256 total)
The size of pattern should therefor be 256 in order to accommodate all possible biome IDs
There might be similar bugs like this elsewhere in world painter

Hope this helps, have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant