|
1 | 1 | package com.kqp.inventorytabs.mixin; |
2 | 2 |
|
3 | | -import java.util.Objects; |
4 | | - |
5 | 3 | import com.kqp.inventorytabs.init.InventoryTabsClient; |
| 4 | +import net.minecraft.client.util.math.MatrixStack; |
| 5 | +import net.minecraft.text.MutableText; |
6 | 6 | import org.spongepowered.asm.mixin.Final; |
7 | 7 | import org.spongepowered.asm.mixin.Mixin; |
8 | 8 | import org.spongepowered.asm.mixin.Shadow; |
|
11 | 11 |
|
12 | 12 | import net.minecraft.client.gui.screen.option.ControlsListWidget; |
13 | 13 | import net.minecraft.client.option.KeyBinding; |
14 | | -import net.minecraft.text.Text; |
15 | | -import net.minecraft.text.TextColor; |
16 | 14 | import net.minecraft.util.Formatting; |
| 15 | +import org.spongepowered.asm.mixin.injection.Redirect; |
17 | 16 |
|
18 | 17 | /** |
19 | 18 | * The 'Tab' keybinding conflicts with the multiplayer player list keybind, but since you can only see the player list when outside the inventory |
|
23 | 22 | public class ControlsListWidget$KeyBindingEntryMixin_SoftConflict { |
24 | 23 | @Shadow @Final private KeyBinding binding; |
25 | 24 |
|
26 | | - @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/ButtonWidget;setMessage(Lnet/minecraft/text/Text;)V")) |
27 | | - public Text setMessage(Text text) { |
28 | | - TextColor c = text.getStyle().getColor(); |
29 | | - if(c != null && c.getRgb() == Objects.requireNonNull(Formatting.RED.getColorValue())) { |
30 | | - if(this.binding == InventoryTabsClient.NEXT_TAB_KEY_BIND) { |
31 | | - text = text.copy().formatted(Formatting.GOLD); |
32 | | - } |
| 25 | + @ModifyArg(method = "render", index = 5, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawableHelper;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V")) |
| 26 | + public int fill(MatrixStack matrices, int x1, int y1, int x2, int y2, int color) { |
| 27 | + if(this.binding == InventoryTabsClient.NEXT_TAB_KEY_BIND) { |
| 28 | + return Formatting.GOLD.getColorValue() | 0xFF000000; |
| 29 | + } |
| 30 | + return color; |
| 31 | + } |
| 32 | + |
| 33 | + @Redirect(method="update", at=@At(value="INVOKE", target="Lnet/minecraft/text/MutableText;formatted(Lnet/minecraft/util/Formatting;)Lnet/minecraft/text/MutableText;")) |
| 34 | + public MutableText formatText(MutableText instance, Formatting formatting) { |
| 35 | + if(formatting == Formatting.RED && this.binding == InventoryTabsClient.NEXT_TAB_KEY_BIND) { |
| 36 | + return instance.formatted(Formatting.GOLD); |
33 | 37 | } |
34 | | - return text; |
| 38 | + return instance.formatted(formatting); |
35 | 39 | } |
36 | 40 | } |
0 commit comments