Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed how keybind button presses is simulated. Should hopefully mak…
…e it work in more instances. Fixed Clipboard/Send button & Toggle/Press button reverting, everytime you edit a button
- Loading branch information
1 parent
0732df2
commit fbb859e
Showing
7 changed files
with
67 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
minecraft_version=1.19.4 | ||
forge_version=45.0.9 | ||
mod_version=1.11.4 | ||
mod_version=1.11.5 | ||
|
||
org.gradle.jvmargs=-Xmx4G | ||
org.gradle.daemon=false |
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
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 |
---|---|---|
|
@@ -37,6 +37,6 @@ public void onClicked() { | |
|
||
@Override | ||
public void onRemoved() { | ||
clipboard = !clipboard; | ||
|
||
} | ||
} |
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
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
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
36 changes: 36 additions & 0 deletions
36
src/main/java/dmillerw/menu/helper/KeyReflectionHelper.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,36 @@ | ||
package dmillerw.menu.helper; | ||
|
||
import cpw.mods.modlauncher.api.INameMappingService; | ||
import dmillerw.menu.handler.LogHandler; | ||
import net.minecraft.client.KeyMapping; | ||
import net.minecraftforge.fml.util.ObfuscationReflectionHelper; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
public class KeyReflectionHelper { | ||
private static Field pressTimeField; | ||
|
||
public static void gatherFields() { | ||
try { | ||
pressTimeField = KeyMapping.class.getDeclaredField(ObfuscationReflectionHelper.remapName(INameMappingService.Domain.FIELD, "f_90818_")); | ||
pressTimeField.setAccessible(true); | ||
} catch (NoSuchFieldException e) { | ||
throwReflectionError("f_90818_", KeyMapping.class); | ||
} | ||
} | ||
|
||
public static void setClickCount(KeyMapping keyBinding, int clickCount) { | ||
try { | ||
pressTimeField.set(keyBinding, clickCount == 0 ? 0 : pressTimeField.getInt(keyBinding) + clickCount); | ||
} catch (IllegalAccessException e) { | ||
e.printStackTrace(); | ||
throwReflectionError("f_90818_", KeyMapping.class); | ||
} | ||
} | ||
|
||
private static void throwReflectionError(String field, Class<?> clazz) { | ||
String error = String.format("Ran into an issue regarding reflection with field %s from %s. REPORT THIS TO THE MOD AUTHOR!", field, clazz.getName()); | ||
LogHandler.fatal(error); | ||
throw new RuntimeException(error); | ||
} | ||
} |