Skip to content

Commit

Permalink
backport to 1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
uku3lig committed Dec 12, 2022
1 parent 3d00698 commit e8b3f82
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/main/java/net/uku3lig/ukulib/config/Position.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ public enum Position {
MIDDLE(4, "ukulib.position.middle"),
;

/**
* The id of the position.
* @return The id
*/
private final int id;
/**
* The translation key of the position.
* @return The translation key
*/
private final String translationKey;

Position(int id, String translationKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ScreenTexts;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import net.uku3lig.ukulib.config.ConfigManager;
import org.lwjgl.glfw.GLFW;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.uku3lig.ukulib.mixin;

import net.minecraft.client.gui.widget.CyclingButtonWidget;
import net.minecraft.client.option.SimpleOption;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.uku3lig.ukulib.utils.Ukutils;
Expand All @@ -27,14 +26,14 @@ public class MixinCyclingButtonWidgetBuilder<T> {
@Shadow private CyclingButtonWidget.Values<T> values;
@Shadow @Final private Function<T, Text> valueToText;
@Shadow private Function<CyclingButtonWidget<T>, MutableText> narrationMessageFactory;
@Shadow private SimpleOption.TooltipFactory<T> tooltipFactory;
@Shadow private CyclingButtonWidget.TooltipFactory<T> tooltipFactory;
@Shadow private boolean optionTextOmitted;

@Inject(method = "build(IIIILnet/minecraft/text/Text;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$UpdateCallback;)Lnet/minecraft/client/gui/widget/CyclingButtonWidget;",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/CyclingButtonWidget;<init>(IIIILnet/minecraft/text/Text;Lnet/minecraft/text/Text;ILjava/lang/Object;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$Values;Ljava/util/function/Function;Ljava/util/function/Function;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$UpdateCallback;Lnet/minecraft/client/option/SimpleOption$TooltipFactory;Z)V"),
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/CyclingButtonWidget;<init>(IIIILnet/minecraft/text/Text;Lnet/minecraft/text/Text;ILjava/lang/Object;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$Values;Ljava/util/function/Function;Ljava/util/function/Function;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$UpdateCallback;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$TooltipFactory;Z)V"),
cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private void fixText(int x, int y, int width, int height, Text optionText, CyclingButtonWidget.UpdateCallback<T> callback, CallbackInfoReturnable<CyclingButtonWidget<T>> cir, List<T> list, T object, Text text, Text text2) {
if (text2.contains(Ukutils.BUTTON_PLACEHOLDER)) text2 = optionText;
if (text2.getString().contains(Ukutils.BUTTON_PLACEHOLDER.getString())) text2 = optionText;

CyclingButtonWidget<T> w = new CyclingButtonWidget<>(x, y, width, height, text2, optionText, this.initialIndex, object, this.values, this.valueToText, this.narrationMessageFactory, callback, this.tooltipFactory, this.optionTextOmitted);
cir.setReturnValue(w);
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/ukulib.accesswidener
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
accessWidener v1 named

accessible method net/minecraft/client/gui/widget/CyclingButtonWidget <init> (IIIILnet/minecraft/text/Text;Lnet/minecraft/text/Text;ILjava/lang/Object;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$Values;Ljava/util/function/Function;Ljava/util/function/Function;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$UpdateCallback;Lnet/minecraft/client/option/SimpleOption$TooltipFactory;Z)V
accessible method net/minecraft/client/gui/widget/CyclingButtonWidget <init> (IIIILnet/minecraft/text/Text;Lnet/minecraft/text/Text;ILjava/lang/Object;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$Values;Ljava/util/function/Function;Ljava/util/function/Function;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$UpdateCallback;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$TooltipFactory;Z)V

accessible class net/minecraft/client/gui/widget/CyclingButtonWidget$Values

0 comments on commit e8b3f82

Please sign in to comment.