Skip to content

Commit

Permalink
Removed ModMenuIntegration.java and added a DH button to option screen
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Oct 22, 2024
1 parent 70df427 commit bbdba6d
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 22 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
yacl_version=3.5.0+1.21-fabric

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<Screen> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/dynamichud.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
"injectors": {
"defaultRequire": 1
},
"client": []
"client": [
"OptionsScreenMixin"
]
}
3 changes: 0 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
"entrypoints": {
"client": [
"com.tanishisherewith.dynamichud.DynamicHUD"
],
"modmenu": [
"com.tanishisherewith.dynamichud.ModMenuIntegration"
]
},
"mixins": [
Expand Down

0 comments on commit bbdba6d

Please sign in to comment.