diff --git a/gradle.properties b/gradle.properties index ec658d7..8d37f3a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ loader_version=0.15.11 fabric_version=0.98.0+1.20.6 # Mod Properties -mod_version=2.4.0 +mod_version=2.4.1 maven_group=org.samo_lego archives_base_name=fabrictailor # Dependencies diff --git a/src/main/java/org/samo_lego/fabrictailor/mixin/client/MSkinCustomizationScreen_SkinButton.java b/src/main/java/org/samo_lego/fabrictailor/mixin/client/MSkinCustomizationScreen_SkinButton.java index 01d57d7..29f8eab 100644 --- a/src/main/java/org/samo_lego/fabrictailor/mixin/client/MSkinCustomizationScreen_SkinButton.java +++ b/src/main/java/org/samo_lego/fabrictailor/mixin/client/MSkinCustomizationScreen_SkinButton.java @@ -1,30 +1,44 @@ package org.samo_lego.fabrictailor.mixin.client; import net.minecraft.client.Options; +import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.components.OptionsList; import net.minecraft.client.gui.screens.OptionsSubScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.SkinCustomizationScreen; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; +import org.jetbrains.annotations.Nullable; import org.samo_lego.fabrictailor.client.ClientTailor; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import java.util.List; + @Mixin(SkinCustomizationScreen.class) public class MSkinCustomizationScreen_SkinButton extends OptionsSubScreen { + public MSkinCustomizationScreen_SkinButton(Screen screen, Options options, Component component) { super(screen, options, component); } - @Inject(method = "init", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD) - private void onInit(CallbackInfo ci, int i) { - if (this.minecraft.player != null) { - this.addRenderableWidget(Button.builder(Component.literal("FabricTailor"), - button -> this.minecraft.setScreen(ClientTailor.SKIN_CHANGE_SCREEN)).bounds(this.width / 2 - 100, this.height / 6 + 24 * (i >> 1) + 22, 200, 20).build()); + @Inject(method = "init", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/components/OptionsList;addSmall(Ljava/util/List;)V" + ), + locals = LocalCapture.CAPTURE_FAILSOFT) + private void onInit(CallbackInfo ci, List widgets) { + if (this.minecraft != null && this.minecraft.player != null) { + var ftButton = Button.builder(Component.literal("FabricTailor"), + button -> this.minecraft.setScreen(ClientTailor.SKIN_CHANGE_SCREEN)).build(); + widgets.add(ftButton); } } }