daveyliam / mapwriter

MapWriter: A minimap mod for Minecraft
MIT License
89 stars 81 forks source link

Minecraft crashed while MapWriter trying to save map as PNG-image #1

Closed nmakoto closed 11 years ago

nmakoto commented 11 years ago

Open map on M bind then press P to save map as png, game will crash. Used mc1.6.2

From log output:

Client> 2013-08-03 01:09:25 [INFO] [MapWriter] merging area (-512,0) -> (0,0)
Client> 2013-08-03 01:09:25 [INFO] [STDERR] java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
Client> 2013-08-03 01:09:25 [INFO] [STDERR]     at sun.awt.image.IntegerInterleavedRaster.setDataElements(IntegerInterleavedRaster.java:301)
Client> 2013-08-03 01:09:25 [INFO] [STDERR]     at java.awt.image.BufferedImage.setRGB(BufferedImage.java:1031)
Client> 2013-08-03 01:09:25 [INFO] [STDERR]     at mapwriter.region.MergeToImage.merge(MergeToImage.java:48)
Client> 2013-08-03 01:09:25 [INFO] [STDERR]     at mapwriter.MergeTask.run(MergeTask.java:31)

As a quick solution, replace line at MergeTask.java:28

BufferedImage mergedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);

on this one:

BufferedImage mergedImage = new BufferedImage(
      (Math.abs(rXMax - rXMin) + 1) << Region.SHIFT,
      (Math.abs(rZMax - rZMin) + 1) << Region.SHIFT,
      BufferedImage.TYPE_INT_ARGB
);
daveyliam commented 11 years ago

Thanks for the bug report. It seems I forgot to make sure that w or h aren't 0 when merging. It should be fixed now in the latest version.