1
0
mirror of https://github.com/chylex/Better-Controls.git synced 2025-05-07 16:34:06 +02:00

Add support for Mod Menu configuration button & set priority on HookOpenScreen

This commit is contained in:
chylex 2020-10-18 12:52:20 +02:00
parent d28ece5759
commit e9a339f025
6 changed files with 38 additions and 7 deletions
build.gradle
src/main
java
chylex/bettercontrols
io/github/prospector/modmenu/api
resources

View File

@ -36,4 +36,5 @@ tasks.withType(JavaCompile) {
jar {
from "LICENSE"
exclude "io/github/prospector/"
}

View File

@ -0,0 +1,11 @@
package chylex.bettercontrols.compatibility;
import chylex.bettercontrols.gui.BetterControlsScreen;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
public class ModMenuSupport implements ModMenuApi{
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory(){
return BetterControlsScreen::new;
}
}

View File

@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MinecraftClient.class)
@Mixin(value = MinecraftClient.class, priority = 100)
public abstract class HookOpenScreen{
@Inject(method = "openScreen(Lnet/minecraft/client/gui/screen/Screen;)V", at = @At("TAIL"))
private void openScreen(final Screen ignore, final CallbackInfo ci){

View File

@ -0,0 +1,8 @@
package io.github.prospector.modmenu.api;
import net.minecraft.client.gui.screen.Screen;
@SuppressWarnings("unused")
@FunctionalInterface
public interface ConfigScreenFactory<S extends Screen>{
S create(Screen var1);
}

View File

@ -0,0 +1,14 @@
package io.github.prospector.modmenu.api;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
@SuppressWarnings("unused")
public interface ModMenuApi{
default ConfigScreenFactory<?> getModConfigScreenFactory(){
return ignore -> null;
}
default Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories(){
return ImmutableMap.of();
}
}

View File

@ -4,7 +4,7 @@
"version": "${version}",
"name": "Better Controls",
"description": "Adds many powerful key bindings and options to control your movement.\nThe features complement vanilla mechanics without giving unfair advantages, so server use should be fine.\nTo configure the mod, open Options - Controls - Better Controls. If you want to see the vanilla Controls screen, hold Alt while opening it.",
"description": "Adds many powerful key bindings and options to control your movement.\nThe features complement vanilla mechanics without giving unfair advantages, so server use should be fine.",
"icon": "assets/bettercontrols/icon.png",
"license": "MPL-2.0",
@ -17,7 +17,8 @@
"environment": "client",
"entrypoints": {
"client": [ "chylex.bettercontrols.BetterControlsMod" ]
"client": [ "chylex.bettercontrols.BetterControlsMod" ],
"modmenu": [ "chylex.bettercontrols.compatibility.ModMenuSupport" ]
},
"mixins": [{
@ -28,9 +29,5 @@
"depends": {
"fabricloader": ">=0.7.4",
"minecraft": "1.16.x"
},
"custom": {
"modmenu:clientsideOnly": true
}
}