From dff6e19b02cf10e71d6e38265348c210f9949078 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Tue, 3 Dec 2024 23:18:08 +0100 Subject: [PATCH] UI fixes, start with mixins --- .../mixin/fixes/minecraft/MixinPlayerListEntry.java | 3 ++- .../florianmichael/viafabricplus/screen/VFPList.java | 12 ++++++------ .../screen/base/ProtocolSelectionScreen.java | 2 +- .../screen/classic4j/BetaCraftScreen.java | 2 +- .../screen/classic4j/ClassiCubeServerListScreen.java | 2 +- .../screen/realms/BedrockRealmsScreen.java | 2 +- .../screen/settings/SettingsScreen.java | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinPlayerListEntry.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinPlayerListEntry.java index feea68362..0bf166fac 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinPlayerListEntry.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinPlayerListEntry.java @@ -32,13 +32,14 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; +import java.util.Optional; import java.util.concurrent.CompletableFuture; @Mixin(PlayerListEntry.class) public abstract class MixinPlayerListEntry { @Redirect(method = "texturesSupplier", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/PlayerSkinProvider;fetchSkinTextures(Lcom/mojang/authlib/GameProfile;)Ljava/util/concurrent/CompletableFuture;")) - private static CompletableFuture fetchGameProfileProperties(PlayerSkinProvider instance, GameProfile profile) { + private static CompletableFuture> fetchGameProfileProperties(PlayerSkinProvider instance, GameProfile profile) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20) && !profile.getProperties().containsKey("textures")) { return CompletableFuture.supplyAsync(() -> { final ProfileResult profileResult = MinecraftClient.getInstance().getSessionService().fetchProfile(profile.getId(), true); diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/VFPList.java b/src/main/java/de/florianmichael/viafabricplus/screen/VFPList.java index 192561a70..99aa68dc2 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/VFPList.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/VFPList.java @@ -30,7 +30,7 @@ * Wrapper class for {@link AlwaysSelectedEntryListWidget} including the following features: *
    *
  • Changing the constructor arguments to be more readable and customizable
  • - *
  • Adds {@link #initScrollAmount(double)} to save the scroll state after closing the screen, requires static tracking by the implementation
  • + *
  • Adds {@link #initScrollY(double)} to save the scroll state after closing the screen, requires static tracking by the implementation
  • *
  • Removes the selection box
  • *
* @@ -43,17 +43,17 @@ public VFPList(MinecraftClient minecraftClient, int width, int height, int top, super(minecraftClient, width, height - top - bottom, top, entryHeight); } - public void initScrollAmount(final double amount) { + public void initScrollY(final double scrollY) { // Needs calling last in init to have data loaded before setting scroll amount if (GeneralSettings.global().saveScrollPositionInSlotScreens.getValue()) { - this.setScrollAmount(amount); + this.setScrollY(scrollY); } } @Override - public void setScrollAmountOnly(double amount) { - super.setScrollAmountOnly(amount); - updateSlotAmount(getScrollAmount()); // Ensure value is clamped + public void setScrollY(double scrollY) { + super.setScrollY(scrollY); + updateSlotAmount(getScrollY()); // Ensure value is clamped } @Override diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/base/ProtocolSelectionScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/base/ProtocolSelectionScreen.java index efbc551bd..0fdf2a2ad 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/base/ProtocolSelectionScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/base/ProtocolSelectionScreen.java @@ -65,7 +65,7 @@ public SlotList(MinecraftClient minecraftClient, int width, int height, int top, super(minecraftClient, width, height, top, bottom, entryHeight); ProtocolVersionList.getProtocolsNewToOld().stream().map(ProtocolSlot::new).forEach(this::addEntry); - initScrollAmount(scrollAmount); + initScrollY(scrollAmount); } @Override diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java index 1c3cdd443..24790bc57 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java @@ -90,7 +90,7 @@ public SlotList(MinecraftClient minecraftClient, int width, int height, int top, } } - initScrollAmount(scrollAmount); + initScrollY(scrollAmount); } @Override diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java index 43f4fd6dc..09a42683d 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java @@ -97,7 +97,7 @@ public SlotList(MinecraftClient minecraftClient, int width, int height, int top, super(minecraftClient, width, height, top, bottom, entryHeight); SERVER_LIST.forEach(serverInfo -> this.addEntry(new ServerSlot(serverInfo))); - initScrollAmount(scrollAmount); + initScrollY(scrollAmount); } @Override diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/realms/BedrockRealmsScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/realms/BedrockRealmsScreen.java index 0a8400913..b28575fe6 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/realms/BedrockRealmsScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/realms/BedrockRealmsScreen.java @@ -166,7 +166,7 @@ public SlotList(MinecraftClient minecraftClient, int width, int height, int top, for (RealmsWorld realmsWorld : BedrockRealmsScreen.this.realmsWorlds) { this.addEntry(new SlotEntry(this, realmsWorld)); } - initScrollAmount(scrollAmount); + initScrollY(scrollAmount); } @Override diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java index 1ff356c08..c43ff740e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java @@ -56,7 +56,7 @@ public SlotList(MinecraftClient minecraftClient, int width, int height, int top, this.addEntry(setting.makeSettingRenderer()); } } - initScrollAmount(scrollAmount); + initScrollY(scrollAmount); } @Override