diff options
author | makamys <makamys@outlook.com> | 2021-05-07 08:42:32 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-07 08:42:32 +0200 |
commit | c233ea31da07957d8872d3859d6e75b99937becd (patch) | |
tree | b9d4301b7b503aa466d4af2db8498918f3e6dfee /src/main/java/makamys/lodmod/util | |
parent | bc6c84d2d2342073b6f4d1b8c1213b7102bb7ebf (diff) | |
download | Neodymium-c233ea31da07957d8872d3859d6e75b99937becd.tar.gz Neodymium-c233ea31da07957d8872d3859d6e75b99937becd.tar.bz2 Neodymium-c233ea31da07957d8872d3859d6e75b99937becd.zip |
Port mod from MCP to Forge!
The only known regression is the sides of LOD=1 chunks look darker for some
reason
Diffstat (limited to 'src/main/java/makamys/lodmod/util')
-rw-r--r-- | src/main/java/makamys/lodmod/util/Util.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/makamys/lodmod/util/Util.java b/src/main/java/makamys/lodmod/util/Util.java new file mode 100644 index 0000000..92cc5cd --- /dev/null +++ b/src/main/java/makamys/lodmod/util/Util.java @@ -0,0 +1,30 @@ +package makamys.lodmod.util; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.nio.file.FileSystems; +import java.nio.file.Path; + +public class Util { + public static Path getResourcePath(String relPath) { + try { + URL resourceURL = Util.class.getClassLoader().getResource(relPath); + + switch(resourceURL.getProtocol()) { + case "jar": + String urlString = resourceURL.getPath(); + int lastExclamation = urlString.lastIndexOf('!'); + String newURLString = urlString.substring(0, lastExclamation); + return FileSystems.newFileSystem(new File(URI.create(newURLString)).toPath(), null).getPath(relPath); + case "file": + return new File(URI.create(resourceURL.toString())).toPath(); + default: + return null; + } + } catch(IOException e) { + return null; + } + } +} |