Prechádzať zdrojové kódy

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

chylex 4 rokov pred
rodič
commit
e9a339f025

+ 1 - 0
build.gradle

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

+ 11 - 0
src/main/java/chylex/bettercontrols/compatibility/ModMenuSupport.java

@@ -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;
+	}
+}

+ 1 - 1
src/main/java/chylex/bettercontrols/mixin/HookOpenScreen.java

@@ -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){

+ 8 - 0
src/main/java/io/github/prospector/modmenu/api/ConfigScreenFactory.java

@@ -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);
+}

+ 14 - 0
src/main/java/io/github/prospector/modmenu/api/ModMenuApi.java

@@ -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();
+	}
+}

+ 3 - 6
src/main/resources/fabric.mod.json

@@ -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
   }
 }