ToroCraft / ToroHealth

GNU General Public License v3.0
64 stars 50 forks source link

Fix color parsing using java.awt.Color #120

Closed unascribed closed 3 years ago

unascribed commented 3 years ago

For reasons known to no-one, using java.awt.Color initializes the AWT Toolkit.

This is illegal in LWJGL3-based versions of Minecraft, and causes strange and hard to debug issues, especially on macOS. These issues generally are hard to see or do not occur on Linux and Windows, unless using other mods that do native tricks like MumbleLink.

This PR removes the usage of java.awt.Color from ColorJsonAdpater (sic) and replaces it with manual parsing. Also changed the writer method to use a proper string format specifier instead of replacing spaces after a string interp.

ColorJsonAdpater should probably get renamed to ColorJsonAdapter, but that's out of the scope of this PR.

frodare commented 3 years ago

Thanks! I will try to get a new build out in next day or so. I think I will add support for the old int color format too to avoid busting the old config files, but that shouldn't be difficult.

unascribed commented 3 years ago

The commit adding it just says "hex color format", so I assumed that was the only format desired. Shouldn't be too hard to implement the others, though.

Main goal here was to inform you of the java.awt problem.

The person who I wrote this patch for I've already sent a build to containing this patch, so, no rush.