|
1 | 1 | package org.samo_lego.fabrictailor.mixin.client; |
2 | 2 |
|
3 | 3 | import net.minecraft.client.Options; |
| 4 | +import net.minecraft.client.gui.components.AbstractWidget; |
4 | 5 | import net.minecraft.client.gui.components.Button; |
| 6 | +import net.minecraft.client.gui.components.OptionsList; |
5 | 7 | import net.minecraft.client.gui.screens.OptionsSubScreen; |
6 | 8 | import net.minecraft.client.gui.screens.Screen; |
7 | 9 | import net.minecraft.client.gui.screens.SkinCustomizationScreen; |
| 10 | +import net.minecraft.network.chat.CommonComponents; |
8 | 11 | import net.minecraft.network.chat.Component; |
| 12 | +import org.jetbrains.annotations.Nullable; |
9 | 13 | import org.samo_lego.fabrictailor.client.ClientTailor; |
10 | 14 | import org.spongepowered.asm.mixin.Mixin; |
| 15 | +import org.spongepowered.asm.mixin.Shadow; |
11 | 16 | import org.spongepowered.asm.mixin.injection.At; |
12 | 17 | import org.spongepowered.asm.mixin.injection.Inject; |
13 | 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
14 | 19 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; |
15 | 20 |
|
| 21 | +import java.util.List; |
| 22 | + |
16 | 23 |
|
17 | 24 | @Mixin(SkinCustomizationScreen.class) |
18 | 25 | public class MSkinCustomizationScreen_SkinButton extends OptionsSubScreen { |
| 26 | + |
19 | 27 | public MSkinCustomizationScreen_SkinButton(Screen screen, Options options, Component component) { |
20 | 28 | super(screen, options, component); |
21 | 29 | } |
22 | 30 |
|
23 | | - @Inject(method = "init", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD) |
24 | | - private void onInit(CallbackInfo ci, int i) { |
25 | | - if (this.minecraft.player != null) { |
26 | | - this.addRenderableWidget(Button.builder(Component.literal("FabricTailor"), |
27 | | - button -> this.minecraft.setScreen(ClientTailor.SKIN_CHANGE_SCREEN)).bounds(this.width / 2 - 100, this.height / 6 + 24 * (i >> 1) + 22, 200, 20).build()); |
| 31 | + @Inject(method = "init", |
| 32 | + at = @At( |
| 33 | + value = "INVOKE", |
| 34 | + target = "Lnet/minecraft/client/gui/components/OptionsList;addSmall(Ljava/util/List;)V" |
| 35 | + ), |
| 36 | + locals = LocalCapture.CAPTURE_FAILSOFT) |
| 37 | + private void onInit(CallbackInfo ci, List<AbstractWidget> widgets) { |
| 38 | + if (this.minecraft != null && this.minecraft.player != null) { |
| 39 | + var ftButton = Button.builder(Component.literal("FabricTailor"), |
| 40 | + button -> this.minecraft.setScreen(ClientTailor.SKIN_CHANGE_SCREEN)).build(); |
| 41 | + widgets.add(ftButton); |
28 | 42 | } |
29 | 43 | } |
30 | 44 | } |
0 commit comments