Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef;
import java.util.Comparator;
import meteordevelopment.meteorclient.systems.friends.Friends;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.BetterTab;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -36,6 +38,29 @@ private long modifyCount(long count) {
return module.isActive() ? module.tabSize.get() : count;
}

@Inject(method = "getPlayerInfos", at = @At("RETURN"), cancellable = true)
private void friendsOnly(CallbackInfoReturnable<List<PlayerInfo>> cir) {
BetterTab betterTab = Modules.get().get(BetterTab.class);

if (betterTab.isActive()) {
List<PlayerInfo> players = cir.getReturnValue();

if (betterTab.onlyFriends.get()) {
players = players.stream()
.filter(info -> info.getProfile().id().equals(Minecraft.getInstance().player.getUUID()) || Friends.get().isFriend(info))
.toList();
}

if (betterTab.friendsFirst.get()) {
players = players.stream()
.sorted(Comparator.comparing(info -> !(info.getProfile().id().equals(Minecraft.getInstance().player.getUUID()) || Friends.get().isFriend(info))))
.toList();
}

cir.setReturnValue(players);
}
}

@Inject(method = "getNameForDisplay", at = @At("HEAD"), cancellable = true)
public void getNameForDisplay(PlayerInfo info, CallbackInfoReturnable<Component> cir) {
BetterTab betterTab = Modules.get().get(BetterTab.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ public class BetterTab extends Module {
.build()
);

public final Setting<Boolean> onlyFriends = sgGeneral.add(new BoolSetting.Builder()
.name("show-only-friends")
.description("Only show friends and yourself in the tablist, nobody else.")
.defaultValue(false)
.build()
);

public final Setting<Boolean> friendsFirst = sgGeneral.add(new BoolSetting.Builder()
.name("show-friends-first")
.description("First show friends and yourself in the tablist, then everyone else.")
.defaultValue(false)
.visible(() -> !onlyFriends.get())
.build()
);

public final Setting<Boolean> accurateLatency = sgGeneral.add(new BoolSetting.Builder()
.name("accurate-latency")
.description("Shows latency as a number in the tablist.")
Expand Down
Loading