diff --git a/build.gradle b/build.gradle index 9f94dfe..5bdb604 100644 --- a/build.gradle +++ b/build.gradle @@ -34,8 +34,6 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}" - - modApi "com.terraformersmc:modmenu:${project.modmenu_version}" } processResources { diff --git a/gradle.properties b/gradle.properties index e2dee65..b1efe41 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,5 +15,4 @@ archives_base_name = dynamichud # Dependencies fabric_version=0.102.1+1.21.1 -yacl_version=3.5.0+1.21-fabric -modmenu_version = 11.0.2 \ No newline at end of file +yacl_version=3.5.0+1.21-fabric \ No newline at end of file diff --git a/src/main/java/com/tanishisherewith/dynamichud/ModMenuIntegration.java b/src/main/java/com/tanishisherewith/dynamichud/ModMenuIntegration.java deleted file mode 100644 index 668a7ed..0000000 --- a/src/main/java/com/tanishisherewith/dynamichud/ModMenuIntegration.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.tanishisherewith.dynamichud; - -import com.tanishisherewith.dynamichud.config.GlobalConfig; -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; - - -public class ModMenuIntegration implements ModMenuApi { - @Override - public ConfigScreenFactory getModConfigScreenFactory() { - return parent -> GlobalConfig.get().createYACLGUI(); - } -} diff --git a/src/main/java/com/tanishisherewith/dynamichud/mixins/OptionsScreenMixin.java b/src/main/java/com/tanishisherewith/dynamichud/mixins/OptionsScreenMixin.java new file mode 100644 index 0000000..772b49d --- /dev/null +++ b/src/main/java/com/tanishisherewith/dynamichud/mixins/OptionsScreenMixin.java @@ -0,0 +1,36 @@ +package com.tanishisherewith.dynamichud.mixins; + +import com.llamalad7.mixinextras.sugar.Local; +import com.tanishisherewith.dynamichud.config.GlobalConfig; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.option.OptionsScreen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.gui.widget.DirectionalLayoutWidget; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.function.Supplier; + +@Mixin(OptionsScreen.class) +public abstract class OptionsScreenMixin extends Screen { + @Shadow protected abstract ButtonWidget createButton(Text message, Supplier screenSupplier); + + protected OptionsScreenMixin(Text title) { + super(title); + } + @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget$Adder;add(Lnet/minecraft/client/gui/widget/Widget;)Lnet/minecraft/client/gui/widget/Widget;", ordinal = 0)) + private void init(CallbackInfo ci, @Local(ordinal = 0) DirectionalLayoutWidget directionalLayoutWidget) { + DirectionalLayoutWidget directionalLayoutWidget2 = directionalLayoutWidget.add(DirectionalLayoutWidget.horizontal()); + + directionalLayoutWidget2.getMainPositioner().marginLeft(-26).marginY(-28); + + ButtonWidget widget = createButton(Text.of("DH"), () -> GlobalConfig.get().createYACLGUI()); + widget.setDimensions(20, 20); + + directionalLayoutWidget2.add(widget); + } +} \ No newline at end of file diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/ContextMenuProperties.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/ContextMenuProperties.java index 2576b4e..ff70053 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/ContextMenuProperties.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/ContextMenuProperties.java @@ -6,6 +6,8 @@ import java.awt.*; public class ContextMenuProperties { + //Note: Not all of these properties are used in all skins or all places. + private Color backgroundColor = new Color(107, 112, 126, 124); private Color borderColor = Color.BLACK; private float borderWidth = 1f; diff --git a/src/main/java/com/tanishisherewith/dynamichud/widgets/TextWidget.java b/src/main/java/com/tanishisherewith/dynamichud/widgets/TextWidget.java index b14a296..64c1ef9 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/widgets/TextWidget.java +++ b/src/main/java/com/tanishisherewith/dynamichud/widgets/TextWidget.java @@ -30,10 +30,10 @@ public class TextWidget extends Widget implements ContextMenuProvider { String dynamicRegistryKey; DynamicValueRegistry dynamicValueRegistry = null; private ContextMenu menu; + public TextWidget() { this(null, null, false, false, Color.WHITE, "unknown"); } - /** * Searches for the supplier within the {@link DynamicValueRegistry#globalRegistry} using the given registryKey * diff --git a/src/main/resources/dynamichud.mixins.json b/src/main/resources/dynamichud.mixins.json index f40333e..f5d7c16 100644 --- a/src/main/resources/dynamichud.mixins.json +++ b/src/main/resources/dynamichud.mixins.json @@ -9,5 +9,7 @@ "injectors": { "defaultRequire": 1 }, - "client": [] + "client": [ + "OptionsScreenMixin" + ] } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 33a2089..6b9036c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,9 +20,6 @@ "entrypoints": { "client": [ "com.tanishisherewith.dynamichud.DynamicHUD" - ], - "modmenu": [ - "com.tanishisherewith.dynamichud.ModMenuIntegration" ] }, "mixins": [