diff --git a/.editorconfig b/.editorconfig
index c055cb5..b60a170 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -17,14 +17,6 @@ indent_style = tab
indent_style = space
indent_size = 2
-[quilt.mod.json]
-indent_style = tab
-tab_width = 2
-
-[*.toml]
-indent_style = tab
-tab_width = 2
-
[*.properties]
indent_style = space
indent_size = 2
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 86b880e..88d128d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -4,7 +4,13 @@
# against bad commits.
name: build
-on: [pull_request, push]
+on:
+ workflow_dispatch:
+ branches: [ "1.21" ]
+ push:
+ branches: [ "1.21" ]
+ pull_request:
+ branches: [ "1.21" ]
jobs:
build:
@@ -33,8 +39,8 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
- if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
+ if: ${{ runner.os == 'Linux' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v4
with:
name: Artifacts
- path: build/libs/
\ No newline at end of file
+ path: build/libs/
diff --git a/README.md b/README.md
index 136aed7..01c9957 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
+
+
# Fix Alt Gr
A simple Minecraft mod that (mostly) fixes the [MC-127862](https://bugs.mojang.com/browse/MC-127862) bug, which sometimes makes the Alt Gr key lock your left control key in a pressed state. It prevents the bug from happening in text fields in most situations.
diff --git a/build.gradle b/build.gradle
index ede6105..502d946 100644
--- a/build.gradle
+++ b/build.gradle
@@ -22,7 +22,7 @@ loom {
splitEnvironmentSourceSets()
mods {
- "fixaltgr" {
+ "fix-alt-gr" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
diff --git a/gradle.properties b/gradle.properties
index c38fffa..15880c4 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -11,7 +11,7 @@ loader_version=0.15.11
# Mod Properties
mod_version=3.0.0+1.21
maven_group=com.mikolajkolek
-archives_base_name=fixaltgr
+archives_base_name=fix-alt-gr
# Dependencies
jnativehook_version=2.2.2
diff --git a/src/client/java/com/mikolajkolek/fixaltgr/FixAltGrClient.java b/src/client/java/com/mikolajkolek/fixaltgr/FixAltGrClient.java
index acd3226..1ae1615 100644
--- a/src/client/java/com/mikolajkolek/fixaltgr/FixAltGrClient.java
+++ b/src/client/java/com/mikolajkolek/fixaltgr/FixAltGrClient.java
@@ -3,17 +3,23 @@
import com.github.kwhat.jnativehook.GlobalScreen;
import com.github.kwhat.jnativehook.NativeHookException;
import net.fabricmc.api.ClientModInitializer;
+import net.minecraft.client.MinecraftClient;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FixAltGrClient implements ClientModInitializer {
- public static final String MODID = "fixaltgr";
+ public static final String MODID = "fix-alt-gr";
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);
public static final GlobalKeyboardListener listener = new GlobalKeyboardListener();
@Override public void onInitializeClient() {
try {
- //FixAltGrLibraryLocator.setAaDefaultLocator();
+ if(StringUtils.containsIgnoreCase(MinecraftClient.getInstance().getVersionType(), "quilt")) {
+ FixAltGrClient.LOGGER.info("FixAltGr detected running on Quilt, correcting library locator...");
+ QuiltLibraryLocator.setAaDefaultLocator();
+ }
+
GlobalScreen.registerNativeHook();
}
catch (NativeHookException ex) {
diff --git a/src/client/java/com/mikolajkolek/fixaltgr/FixAltGrLibraryLocator.java b/src/client/java/com/mikolajkolek/fixaltgr/QuiltLibraryLocator.java
similarity index 64%
rename from src/client/java/com/mikolajkolek/fixaltgr/FixAltGrLibraryLocator.java
rename to src/client/java/com/mikolajkolek/fixaltgr/QuiltLibraryLocator.java
index 35e8dac..8d1d09e 100644
--- a/src/client/java/com/mikolajkolek/fixaltgr/FixAltGrLibraryLocator.java
+++ b/src/client/java/com/mikolajkolek/fixaltgr/QuiltLibraryLocator.java
@@ -1,107 +1,114 @@
-package com.mikolajkolek.fixaltgr;
-
-import com.github.kwhat.jnativehook.NativeLibraryLocator;
-
-import java.io.File;
-import java.util.Iterator;
-
-public class FixAltGrLibraryLocator implements NativeLibraryLocator {
- public static void setAaDefaultLocator() {
- System.setProperty("jnativehook.lib.locator", FixAltGrLibraryLocator.class.getCanonicalName());
- }
-
- // This code is based on the JNativeHook class DefaultLibraryLocator
- // You can find the class together with the whole source code at https://github.com/kwhat/jnativehook/
- @Override
- public Iterator getLibraries() {
- /*List libraries = new ArrayList<>(1);
-
- String libName = System.getProperty("jnativehook.lib.name", "JNativeHook");
-
- // Get the package name for the GlobalScreen.
- String basePackage = GlobalScreen.class.getPackage().getName().replace('.', '/');
-
- String libNativeArch = NativeSystem.getArchitecture().toString().toLowerCase();
- String libNativeName = System
- .mapLibraryName(libName) // Get what the system "thinks" the library name should be.
- .replaceAll("\\.jnilib$", "\\.dylib"); // Hack for OS X JRE 1.6 and earlier.
-
- // Resource path for the native library.
- String libResourcePath = "/" + basePackage + "/lib/" +
- NativeSystem.getFamily().toString().toLowerCase() +
- '/' + libNativeArch + '/' + libNativeName;
-
- String classLocation;
- if(FabricLoader.getInstance().isDevelopmentEnvironment())
- classLocation = GlobalScreen.class.getProtectionDomain().getCodeSource().getLocation().toString();
- else
- classLocation = FabricLoader.getInstance().getModContainer(FixAltGrClient.MODID).get().get().get(0).get(0).toString();
-
- File classFile;
- try {
- classFile = new File(new URI(classLocation));
- }
- catch (URISyntaxException e) {
- FixAltGr.LOGGER.warn(e.getMessage());
- classFile = new File(classLocation);
- }
-
- File libFile;
- if (classFile.isFile()) {
- // Jar Archive
- String libPath = System.getProperty("jnativehook.lib.path", classFile.getParentFile().getPath());
-
- InputStream resourceInputStream = GlobalScreen.class.getResourceAsStream(libResourcePath);
- if (resourceInputStream == null) {
- throw new RuntimeException("Unable to extract the native library " + libResourcePath + "!\n");
- }
-
- String version = GlobalScreen.class.getPackage().getImplementationVersion();
- if (version != null) {
- version = '-' + version;
- } else {
- version = "";
- }
-
- libFile = new File(
- libPath,
- libNativeName.replaceAll("^(.*)\\.(.*)$", "$1" + version + '.' + libNativeArch + ".$2")
- );
- if (!libFile.exists()) {
- try {
- // Check and see if a copy of the native lib already exists.
- FileOutputStream libOutputStream = new FileOutputStream(libFile);
-
- // Read from the digest stream and write to the file steam.
- int size;
- byte[] buffer = new byte[4 * 1024];
- while ((size = resourceInputStream.read(buffer)) != -1) {
- libOutputStream.write(buffer, 0, size);
- }
-
- // Close all the streams.
- resourceInputStream.close();
- libOutputStream.close();
- }
- catch (IOException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
-
- FixAltGr.LOGGER.info("Extracted library: " + libFile.getPath() + ".\n");
- }
- } else {
- // Loose Classes
- libFile = Paths.get(classFile.getAbsolutePath(), libResourcePath).toFile();
- }
-
- if (!libFile.exists()) {
- throw new RuntimeException("Unable to locate JNI library at " + libFile.getPath() + "!\n");
- }
-
- FixAltGr.LOGGER.info("Loading library: " + libFile.getPath() + ".\n");
- libraries.add(libFile);
-
- return libraries.iterator();*/
- return null;
- }
-}
+package com.mikolajkolek.fixaltgr;
+
+import com.github.kwhat.jnativehook.GlobalScreen;
+import com.github.kwhat.jnativehook.NativeLibraryLocator;
+import com.github.kwhat.jnativehook.NativeSystem;
+import net.fabricmc.loader.api.FabricLoader;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class QuiltLibraryLocator implements NativeLibraryLocator {
+ public static void setAaDefaultLocator() {
+ System.setProperty("jnativehook.lib.locator", QuiltLibraryLocator.class.getCanonicalName());
+ }
+
+ // This code is based on the JNativeHook class DefaultLibraryLocator
+ // You can find the class together with the whole source code at https://github.com/kwhat/jnativehook/
+ @Override
+ public Iterator getLibraries() {
+ List libraries = new ArrayList<>(1);
+
+ String libName = System.getProperty("jnativehook.lib.name", "JNativeHook");
+
+ // Get the package name for the GlobalScreen.
+ String basePackage = GlobalScreen.class.getPackage().getName().replace('.', '/');
+
+ String libNativeArch = NativeSystem.getArchitecture().toString().toLowerCase();
+ String libNativeName = System
+ .mapLibraryName(libName) // Get what the system "thinks" the library name should be.
+ .replaceAll("\\.jnilib$", "\\.dylib"); // Hack for OS X JRE 1.6 and earlier.
+
+ // Resource path for the native library.
+ String libResourcePath = "/" + basePackage + "/lib/" +
+ NativeSystem.getFamily().toString().toLowerCase() +
+ '/' + libNativeArch + '/' + libNativeName;
+
+ // classLocation change required by the Quilt Loader
+ String classLocation = FabricLoader.getInstance().getModContainer(FixAltGrClient.MODID).get().getOrigin().getPaths().get(0).toString();
+
+ File classFile;
+ try {
+ classFile = new File(new URI(classLocation));
+ }
+ catch (URISyntaxException e) {
+ FixAltGrClient.LOGGER.warn(e.getMessage());
+ classFile = new File(classLocation);
+ }
+
+ File libFile;
+ if (classFile.isFile()) {
+ // Jar Archive
+ String libPath = System.getProperty("jnativehook.lib.path", classFile.getParentFile().getPath());
+
+ InputStream resourceInputStream = GlobalScreen.class.getResourceAsStream(libResourcePath);
+ if (resourceInputStream == null) {
+ throw new RuntimeException("Unable to extract the native library " + libResourcePath + "!\n");
+ }
+
+ String version = GlobalScreen.class.getPackage().getImplementationVersion();
+ if (version != null) {
+ version = '-' + version;
+ } else {
+ version = "";
+ }
+
+ libFile = new File(
+ libPath,
+ libNativeName.replaceAll("^(.*)\\.(.*)$", "$1" + version + '.' + libNativeArch + ".$2")
+ );
+ if (!libFile.exists()) {
+ try {
+ // Check and see if a copy of the native lib already exists.
+ FileOutputStream libOutputStream = new FileOutputStream(libFile);
+
+ // Read from the digest stream and write to the file steam.
+ int size;
+ byte[] buffer = new byte[4 * 1024];
+ while ((size = resourceInputStream.read(buffer)) != -1) {
+ libOutputStream.write(buffer, 0, size);
+ }
+
+ // Close all the streams.
+ resourceInputStream.close();
+ libOutputStream.close();
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ FixAltGrClient.LOGGER.info("Extracted library: " + libFile.getPath() + ".\n");
+ }
+ } else {
+ // Loose Classes
+ libFile = Paths.get(classFile.getAbsolutePath(), libResourcePath).toFile();
+ }
+
+ if (!libFile.exists()) {
+ throw new RuntimeException("Unable to locate JNI library at " + libFile.getPath() + "!\n");
+ }
+
+ FixAltGrClient.LOGGER.info("Loading library: " + libFile.getPath() + ".\n");
+ libraries.add(libFile);
+
+ return libraries.iterator();
+ }
+}
diff --git a/src/client/java/com/mikolajkolek/fixaltgr/mixin/InputUtilMixin.java b/src/client/java/com/mikolajkolek/fixaltgr/mixin/InputUtilMixin.java
index 7e460ed..e058e5d 100644
--- a/src/client/java/com/mikolajkolek/fixaltgr/mixin/InputUtilMixin.java
+++ b/src/client/java/com/mikolajkolek/fixaltgr/mixin/InputUtilMixin.java
@@ -14,10 +14,8 @@ public class InputUtilMixin { //69696969696969 jubert to nooooobek
private static void isKeyPressed(long window, int code, CallbackInfoReturnable cir) {
if(code != 341) return;
- if(!FixAltGrClient.listener.controlKeyPressed || FixAltGrClient.listener.altKeyPressed) {
+ if(!FixAltGrClient.listener.controlKeyPressed || FixAltGrClient.listener.altKeyPressed)
cir.setReturnValue(false);
- FixAltGrClient.LOGGER.info("IT'S WORKING");
- }
else {
try {
TimeUnit.MILLISECONDS.sleep(10);
@@ -26,10 +24,8 @@ private static void isKeyPressed(long window, int code, CallbackInfoReturnable