-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Requires glfw3.dll in assets/borderlessmining to build; from comp500/glfw@08b3a9e See #19 for more details.
- Loading branch information
Showing
3 changed files
with
51 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/link/infra/borderlessmining/GLFWReplace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package link.infra.borderlessmining; | ||
|
||
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.lwjgl.glfw.GLFW; | ||
import org.lwjgl.system.Configuration; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.nio.file.StandardCopyOption; | ||
|
||
public class GLFWReplace implements PreLaunchEntrypoint { | ||
private final Logger LOGGER = LogManager.getLogger("BorderlessMining 2?"); | ||
|
||
@Override | ||
public void onPreLaunch() { | ||
Path dllCopyPath = Paths.get(".borderlessmining", "glfw3.dll"); | ||
|
||
try { | ||
Files.createDirectories(dllCopyPath.getParent()); | ||
InputStream stream = GLFWReplace.class.getClassLoader().getResourceAsStream("assets/borderlessmining/glfw3.dll"); | ||
if (stream == null) { | ||
LOGGER.error("Failed to read GLFW dll"); | ||
} else { | ||
Files.copy(stream, dllCopyPath, StandardCopyOption.REPLACE_EXISTING); | ||
Configuration.GLFW_LIBRARY_NAME.set(dllCopyPath.toString()); | ||
String glfwVersionString = GLFW.glfwGetVersionString(); | ||
if (glfwVersionString.contains("BorderlessMining")) { | ||
LOGGER.info("GLFW replaced, version string: " + glfwVersionString); | ||
} else { | ||
LOGGER.error("GLFW replacement failed! Version string: " + glfwVersionString); | ||
} | ||
} | ||
} catch (IOException e) { | ||
LOGGER.error("Failed to copy GLFW dll", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters