Skip to content

Commit

Permalink
fix button in open link gui not being centered (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexdoru authored Oct 20, 2024
1 parent 7b12b54 commit 7c0774b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ public class FixesConfig {
// settings
public static int limitRecursiveBlockUpdateDepth;

@Config.Comment("Fix the buttons not being centered in the GuiConfirmOpenLink")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean fixButtonsGuiConfirmOpenLink;

@Config.Comment("Fix an array out of bounds caused by the GameSettings getKeyDisplayString method")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ public enum Mixins {
.addMixinClasses("minecraft.MixinWorldServer_LimitUpdateRecursion")
.setApplyIf(() -> FixesConfig.limitRecursiveBlockUpdateDepth >= 0)),

FIX_BUTTON_POS_GUIOPENLINK(new Builder("Fix the buttons not being centered in the GuiConfirmOpenLink")
.setPhase(Phase.EARLY).setSide(Side.CLIENT).addTargetedMod(TargetedMod.VANILLA)
.addMixinClasses("minecraft.MixinGuiConfirmOpenLink")
.setApplyIf(() -> FixesConfig.fixButtonsGuiConfirmOpenLink)),

FIX_CHAT_OPEN_LINK(new Builder("Fix the vanilla method to open chat links not working for every OS")
.setPhase(Phase.EARLY).setSide(Side.CLIENT).addTargetedMod(TargetedMod.VANILLA)
.addMixinClasses("minecraft.MixinGuiChat_OpenLinks").setApplyIf(() -> FixesConfig.fixChatOpenLink)),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.mitchej123.hodgepodge.mixins.early.minecraft;

import net.minecraft.client.gui.GuiConfirmOpenLink;
import net.minecraft.client.gui.GuiScreen;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

@Mixin(GuiConfirmOpenLink.class)
public class MixinGuiConfirmOpenLink extends GuiScreen {

@ModifyArg(
method = "initGui",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/GuiButton;<init>(IIIIILjava/lang/String;)V",
ordinal = 0),
index = 1)
private int hodgepodge$fixButton0(int xPos) {
return this.width / 2 - 50 - 105;
}

@ModifyArg(
method = "initGui",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/GuiButton;<init>(IIIIILjava/lang/String;)V",
ordinal = 1),
index = 1)
private int hodgepodge$fixButton1(int xPos) {
return this.width / 2 - 50;
}

@ModifyArg(
method = "initGui",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/GuiButton;<init>(IIIIILjava/lang/String;)V",
ordinal = 2),
index = 1)
private int hodgepodge$fixButton2(int xPos) {
return this.width / 2 - 50 + 105;
}

}

0 comments on commit 7c0774b

Please sign in to comment.