Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix button in open link GuiScreen not being centered #428

Merged
merged 2 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

}