Skip to content

Commit

Permalink
Use the glfw-async native on macosx to fix the AWT incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenraven committed Feb 14, 2023
1 parent ee2a9fd commit 49e85ce
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
15 changes: 13 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1675859611
//version: 1676031737
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand All @@ -9,6 +9,7 @@
import com.diffplug.blowdryer.Blowdryer
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.gtnewhorizons.retrofuturagradle.ObfuscationAttribute
import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar
import com.gtnewhorizons.retrofuturagradle.minecraft.RunMinecraftTask
import com.matthewprenger.cursegradle.CurseArtifact
Expand Down Expand Up @@ -70,7 +71,7 @@ plugins {
id 'com.diffplug.spotless' version '6.7.2' apply false
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.5'
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.6'
}
boolean settingsupdated = verifySettingsGradle()
settingsupdated = verifyGitAttributes() || settingsupdated
Expand Down Expand Up @@ -415,6 +416,16 @@ configurations.configureEach {
}
}
}
def obfuscationAttr = it.attributes.getAttribute(ObfuscationAttribute.OBFUSCATION_ATTRIBUTE)
if (obfuscationAttr != null && obfuscationAttr.name == ObfuscationAttribute.SRG) {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
// Remap CoFH core cursemaven dev jar to the obfuscated version for runObfClient/Server
if (details.requested.group == 'curse.maven' && details.requested.name.endsWith('-69162') && details.requested.version == '2388751') {
details.useVersion '2388750'
details.because 'Pick obfuscated jar'
}
}
}
}

// Ensure tests have access to minecraft classes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"version": "${version}",
"order": 3,
"+jvmArgs": [
"-Djava.security.manager=allow",
"--illegal-access=warn",
"-Djava.security.manager=allow",
"-Dfile.encoding=UTF-8",
"--add-opens", "java.base/jdk.internal.loader=ALL-UNNAMED",
"--add-opens", "java.base/java.net=ALL-UNNAMED",
"--add-opens", "java.base/java.nio=ALL-UNNAMED",
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/me/eigenraven/lwjgl3ify/core/Lwjgl3ifyCoremod.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.eigenraven.lwjgl3ify.core;

import java.awt.*;
import java.util.List;
import java.util.Map;

Expand All @@ -9,9 +10,12 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.system.Configuration;
import org.lwjgl.system.Platform;
import org.spongepowered.asm.launch.GlobalProperties;
import org.spongepowered.asm.service.mojang.MixinServiceLaunchWrapper;

import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;

@IFMLLoadingPlugin.MCVersion("1.7.10")
Expand All @@ -35,9 +39,16 @@ public Lwjgl3ifyCoremod() {
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
// AWT event loop deadlocks the main thread with Lwjgl3
System.setProperty("java.awt.headless", "true");
if (FMLLaunchHandler.side().isClient()) {
clientMacOsFix();
}
}

private void clientMacOsFix() {
if (Platform.get() == Platform.MACOSX) {
Configuration.GLFW_LIBRARY_NAME.set("glfw_async");
Configuration.GLFW_CHECK_THREAD0.set(false);
Toolkit.getDefaultToolkit(); // Initialize AWT before GLFW
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public abstract class MixinStitcher {

@Shadow
@Final
private Set setStitchHolders = new HashSet(256);
private Set setStitchHolders;

@Shadow
private int currentWidth;
Expand Down

0 comments on commit 49e85ce

Please sign in to comment.