Skip to content
This repository was archived by the owner on Feb 22, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img alt="Logo" src="src/main/resources/assets/nmuk/icon.svg" />
<img alt="Logo" src="common/src/main/resources/icon.svg" />

# No More Useless Keys

Expand Down
215 changes: 60 additions & 155 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,174 +1,79 @@
plugins {
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'maven-publish'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'com.modrinth.minotaur' version '2.1.1'
id 'org.cadixdev.licenser' version '0.6.1'
id 'dev.architectury.loom' version '1.6-SNAPSHOT' apply false
id 'architectury-plugin' version '3.4-SNAPSHOT'
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_16
architectury {
minecraft = project.minecraft_version
}

archivesBaseName = project.archives_base_name
version = "${project.mod_version}+mc${project.minecraft_version}"
group = project.maven_group
allprojects {
version = "${project.mod_version}+mc${project.minecraft_version}"
group = project.maven_group
}

loom {
accessWidenerPath = file("src/main/resources/nmuk.accesswidener")
subprojects {
apply plugin: 'dev.architectury.loom'
apply plugin: 'architectury-plugin'
apply plugin: 'maven-publish'

base {
archivesName = rootProject.archives_base_name
}

repositories {
maven {
name "Siphalor's Maven"
url "https://maven.siphalor.de"
}
maven { url "https://jitpack.io" }
mavenLocal()
}

dependencies {
minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
mappings "net.fabricmc:yarn:$rootProject.yarn_mappings:v2"
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

processResources {
def substitutions = [
"mod_id": mod_id,
"mod_version": mod_version,
"mod_name": mod_name,
"mod_authors": mod_authors,
"mod_description": mod_description,
"forge_version": forge_version,
"minecraft_version_range": minecraft_version_range
]
inputs.properties(substitutions)

filesMatching(['fabric.mod.json', 'META-INF/mods.toml', 'pack.mcmeta']) {
expand(substitutions)
}
}
}

/*

sourceSets {
testmod {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
}
}*/

repositories {
maven {
name "Siphalor's Maven"
url "https://maven.siphalor.de"
}
maven { url "https://jitpack.io" }
mavenLocal()
}

dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation("de.siphalor:amecsapi-${project.minecraft_major_version}:1.4.0+mc1.20-pre1") {
exclude group: "net.fabricmc.fabric-api"
exclude module: "nmuk-${project.minecraft_major_version}"
}

[
"fabric-api-base",
"fabric-key-binding-api-v1",
"fabric-resource-loader-v0"
].each {
include(modApi(fabricApi.module(it, project.fabric_api_version)))
}

testmodImplementation sourceSets.main.output
}

license {
header = project.file('LICENSE_HEADER')

include '**/*.java'
}

processResources {
inputs.property "version", version

afterEvaluate {
from(sourceSets.main.resources.srcDirs) {
exclude "*.svg"
include "fabric.mod.json"
expand "version": version
duplicatesStrategy DuplicatesStrategy.INCLUDE
}
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
tasks.register('sourcesJar', Jar) {
dependsOn classes
archiveClassifier.set("sources")
from sourceSets.main.allSource
}

jar {
from "LICENSE"
}

// configure the maven publication
publishing {
publications {
create("fabricMod", MavenPublication) {
artifactId = project.archives_base_name + '-' + project.minecraft_major_version
// add all the jars that should be included when publishing to maven

from components.java
java.withSourcesJar()
}
}

// select the repositories you want to publish to
repositories {
if (project.hasProperty("siphalorMavenUser")) {
maven {
name = "Siphalor"
url = "https://maven.siphalor.de/upload.php"
credentials {
username = siphalorMavenUser
password = siphalorMavenPassword
}
}
}
}
}

// Mod sites

static def getChangelog() {
return 'git log -1 --format=format:##%x20%s%n%n%b%nRelease%x20by%x20%an --grep Version'.execute().text.trim()
}

tasks.register('uploadToModSites') {
dependsOn build
group = "upload"
}

if (project.hasProperty("curseforgeToken")) {
curseforge {
apiKey project.curseforgeToken
project {
id = "438172"
releaseType = project.mod_release
changelogType = "markdown"
changelog = project.getChangelog()
addGameVersion("Fabric")
String mcVersions = project.hasProperty("curseforge_mc_versions") ? project.curseforge_mc_versions : project.mod_mc_versions
for (version in mcVersions.split(";")) {
addGameVersion(version)
}
relations {
embeddedLibrary "fabric-api"
optionalDependency "amecs"
}
mainArtifact(remapJar) {
displayName = "[${project.mod_mc_version_specifier}] ${project.mod_version}"
}
}
}
uploadToModSites.finalizedBy(tasks.curseforge)
}

modrinth {
if (project.hasProperty("modrinthToken")) {
token = project.modrinthToken
uploadToModSites.finalizedBy(tasks.modrinth)
}

projectId = "YCcdA1Lp"
versionName = "[${project.mod_mc_version_specifier}] ${project.mod_version}"
versionType = project.mod_release
changelog = project.getChangelog()
uploadFile = remapJar
gameVersions.set(project.mod_mc_versions.split(";") as List<String>)
loaders.set(["fabric"])
options.encoding = "UTF-8"
}
tasks.modrinth.group = "upload"
17 changes: 17 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
architectury {
common rootProject.enabled_platforms.split(',')
}

dependencies {
// We depend on Fabric Loader here to use the Fabric @Environment annotations,
// which get remapped to the correct annotations on each platform.
// Do NOT use other classes from Fabric Loader.
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"

// Architectury API. This is optional, and you can comment it out if you don't need it.
modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version"
}

loom {
accessWidenerPath = file("src/main/resources/nmuk.accesswidener")
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package de.siphalor.nmuk.api;

import de.siphalor.nmuk.impl.IKeyBinding;
import de.siphalor.nmuk.impl.NMUKKeyBinding;
import de.siphalor.nmuk.impl.NMUKKeyBindingHelper;
import de.siphalor.nmuk.impl.mixin.KeyBindingAccessor;
import net.minecraft.client.option.KeyBinding;
Expand Down Expand Up @@ -64,10 +64,10 @@ public static void create(KeyBinding base, InputUtil.Type inputType, int code) {
* @param alternative The alternative keybinding. This keybinding MUST NOT be registered yet
*/
public static void create(KeyBinding base, KeyBinding alternative) {
((KeyBindingAccessor) alternative).setTranslationKey(base.getTranslationKey() + "%" + ((IKeyBinding) base).nmuk_getNextChildId());
((KeyBindingAccessor) alternative).setTranslationKey(base.getTranslationKey() + "%" + ((NMUKKeyBinding) base).nmuk_getNextChildId());
((KeyBindingAccessor) alternative).setCategory(base.getCategory());
((IKeyBinding) base).nmuk_addAlternative(alternative);
((IKeyBinding) alternative).nmuk_setParent(base);
((NMUKKeyBinding) base).nmuk_addAlternative(alternative);
((NMUKKeyBinding) alternative).nmuk_setParent(base);
NMUKKeyBindingHelper.registerKeyBinding(alternative);
NMUKKeyBindingHelper.defaultAlternatives.put(base, alternative);
}
Expand All @@ -79,7 +79,7 @@ public static void create(KeyBinding base, KeyBinding alternative) {
* @return Whether the given keybinding is an alternative
*/
public static boolean isAlternative(KeyBinding binding) {
return ((IKeyBinding) binding).nmuk_isAlternative();
return ((NMUKKeyBinding) binding).nmuk_isAlternative();
}

/**
Expand All @@ -90,7 +90,7 @@ public static boolean isAlternative(KeyBinding binding) {
*/
@Nullable
public static List<KeyBinding> getAlternatives(KeyBinding binding) {
return ((IKeyBinding) binding).nmuk_getAlternatives();
return ((NMUKKeyBinding) binding).nmuk_getAlternatives();
}

/**
Expand All @@ -100,6 +100,6 @@ public static List<KeyBinding> getAlternatives(KeyBinding binding) {
* @return The base keyinding or <code>null</code> if the given keybinding is no alternative
*/
public static KeyBinding getBase(KeyBinding binding) {
return ((IKeyBinding) binding).nmuk_getParent();
return ((NMUKKeyBinding) binding).nmuk_getParent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,20 @@

package de.siphalor.nmuk.impl;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import org.jetbrains.annotations.ApiStatus;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;

@ApiStatus.Internal
public class AlternativeKeyBinding extends KeyBinding {
public AlternativeKeyBinding(KeyBinding parent, String translationKey, int code, String category) {
super(translationKey, code, category);
((IKeyBinding) this).nmuk_setParent(parent);
((NMUKKeyBinding) this).nmuk_setParent(parent);
}

public AlternativeKeyBinding(KeyBinding parent, String translationKey, InputUtil.Type type, int code, String category) {
super(translationKey, type, code, category);
((IKeyBinding) this).nmuk_setParent(parent);
((NMUKKeyBinding) this).nmuk_setParent(parent);
}

@Override
Expand All @@ -44,24 +40,4 @@ public boolean isDefault() {
}
return super.isDefault();
}

private static final MethodHandle INCREMENT_TIMES_PRESSED_SUPER;
static {
MethodHandle methodHandle;
try {
methodHandle = MethodHandles.lookup().unreflectSpecial(KeyBinding.class.getDeclaredMethod("amecs$incrementTimesPressed"), AlternativeKeyBinding.class);
} catch (NoSuchMethodException | IllegalAccessException e) {
if (FabricLoader.getInstance().isModLoaded("amecsapi")) {
throw new RuntimeException("Failed to initialize NMUK compatibility with Amecs", e);
}
methodHandle = null;
}
INCREMENT_TIMES_PRESSED_SUPER = methodHandle;
}
public void amecs$incrementTimesPressed() throws Throwable {
INCREMENT_TIMES_PRESSED_SUPER.invoke(this);

KeyBinding parent = ((IKeyBinding) this).nmuk_getParent();
((de.siphalor.amecs.impl.duck.IKeyBinding) parent).amecs$incrementTimesPressed();
}
}
13 changes: 13 additions & 0 deletions common/src/main/java/de/siphalor/nmuk/impl/ModifierHandle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.siphalor.nmuk.impl;

import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.client.option.KeyBinding;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
public class ModifierHandle {
@ExpectPlatform
public static void resetKeyModifiers(KeyBinding keyBinding) {
throw new AssertionError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.List;

@ApiStatus.Internal
public interface IKeyBinding {
public interface NMUKKeyBinding {
short nmuk_getNextChildId();

void nmuk_setNextChildId(short nextChildId);
Expand Down
Loading