Skip to content

Commit

Permalink
UI fixes, start with mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Dec 3, 2024
1 parent 8791509 commit dff6e19
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SkinTextures> fetchGameProfileProperties(PlayerSkinProvider instance, GameProfile profile) {
private static CompletableFuture<Optional<SkinTextures>> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* Wrapper class for {@link AlwaysSelectedEntryListWidget} including the following features:
* <ul>
* <li>Changing the constructor arguments to be more readable and customizable</li>
* <li>Adds {@link #initScrollAmount(double)} to save the scroll state after closing the screen, requires static tracking by the implementation</li>
* <li>Adds {@link #initScrollY(double)} to save the scroll state after closing the screen, requires static tracking by the implementation</li>
* <li>Removes the selection box</li>
* </ul>
*
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public SlotList(MinecraftClient minecraftClient, int width, int height, int top,
}
}

initScrollAmount(scrollAmount);
initScrollY(scrollAmount);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public SlotList(MinecraftClient minecraftClient, int width, int height, int top,
this.addEntry(setting.makeSettingRenderer());
}
}
initScrollAmount(scrollAmount);
initScrollY(scrollAmount);
}

@Override
Expand Down

0 comments on commit dff6e19

Please sign in to comment.