From 158097b193b83757d9b776809a7252483232e1d1 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Sat, 11 Jan 2025 16:32:12 +0100 Subject: [PATCH] Backport 1.20.2 --- .github/workflows/tag.yml | 18 +++++++++++ settings.json | 1 + .../vanilla/PlayerListComponent.java | 15 ++++++++- .../tr7zw/exordium/util/ScoreboardHelper.java | 32 ++++++++++++++++--- 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index e9ef9d1..023e7dc 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -20,6 +20,24 @@ jobs: uses: softprops/action-gh-release@v1 with: files: 'versions/**/build/libs/!(*-@(dev|sources|javadoc|all)).jar' + - name: Publish-1.20.2-fabric-Curseforge + uses: Kir-Antipov/mc-publish@v3.3.0 + with: + curseforge-id: 681953 + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + loaders: fabric + name: ${{github.ref_name}}-1.20.2 - Fabric + files: 'versions/1.20.2-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar' + game-versions: 1.20.2 + - name: Publish-1.20.2-fabric-Modrinth + uses: Kir-Antipov/mc-publish@v3.3.0 + with: + modrinth-id: DynYZEae + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + loaders: fabric + name: ${{github.ref_name}}-1.20.2 - Fabric + files: 'versions/1.20.2-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar' + game-versions: 1.20.2 - name: Publish-1.20.4-fabric-Curseforge uses: Kir-Antipov/mc-publish@v3.3.0 with: diff --git a/settings.json b/settings.json index 272e0c5..8f3e5d6 100644 --- a/settings.json +++ b/settings.json @@ -1,5 +1,6 @@ { "versions": [ + "1.20.2-fabric", "1.20.4-fabric", "1.20.6-fabric", "1.21-fabric", diff --git a/src/main/java/dev/tr7zw/exordium/components/vanilla/PlayerListComponent.java b/src/main/java/dev/tr7zw/exordium/components/vanilla/PlayerListComponent.java index 75d7554..b91b158 100644 --- a/src/main/java/dev/tr7zw/exordium/components/vanilla/PlayerListComponent.java +++ b/src/main/java/dev/tr7zw/exordium/components/vanilla/PlayerListComponent.java @@ -16,10 +16,14 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.GameType; import net.minecraft.world.scores.Objective; -import net.minecraft.world.scores.PlayerScoreEntry; import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.Scoreboard; import net.minecraft.world.scores.criteria.ObjectiveCriteria; +//#if MC >= 12004 +import net.minecraft.world.scores.PlayerScoreEntry; +//#else +//$$ import net.minecraft.world.scores.Score; +//#endif public class PlayerListComponent implements BufferComponent { @@ -63,8 +67,13 @@ public boolean scoreboardOrObjectiveChanged(Scoreboard scoreboard, Objective obj return false; int scoreboardHashCode = 1; + //#if MC >= 12004 for (PlayerScoreEntry score : scoreboard.listPlayerScores(objective)) scoreboardHashCode = 31 * scoreboardHashCode + (score == null ? 0 : score.value()); + //#else + //$$for (Score score : scoreboard.getPlayerScores(objective)) + //$$ scoreboardHashCode = 31 * scoreboardHashCode + (score == null ? 0 : score.getScore()); + //#endif int newObjectiveHashCode = objective == null ? 0 : objective.getName().hashCode(); if (scoreboardHashCode == scoreboardHash && newObjectiveHashCode == objectiveHash) @@ -107,7 +116,11 @@ public List fastGetPlayerInfoListHashCode(PlayerListContext context, Li PlayerTabOverlay.HealthState healthState = context.tablist().getHealthStates().computeIfAbsent( playerInfo.getProfile().getId(), (_uuid) -> new PlayerTabOverlay.HealthState(lastTrackedObjective.getScoreboard() + //#if MC >= 12004 .getOrCreatePlayerScore(player, lastTrackedObjective).get())); + //#else + //$$.getOrCreatePlayerScore(player.getName().toString(), lastTrackedObjective).getScore())); + //#endif playerHash += healthState.isBlinking(context.tablist.getGui().getGuiTicks()) ? 63 : 127; } } diff --git a/src/main/java/dev/tr7zw/exordium/util/ScoreboardHelper.java b/src/main/java/dev/tr7zw/exordium/util/ScoreboardHelper.java index b6b6db7..8fc8cd1 100644 --- a/src/main/java/dev/tr7zw/exordium/util/ScoreboardHelper.java +++ b/src/main/java/dev/tr7zw/exordium/util/ScoreboardHelper.java @@ -11,12 +11,16 @@ import lombok.experimental.UtilityClass; import net.minecraft.client.Minecraft; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.numbers.NumberFormat; import net.minecraft.world.scores.DisplaySlot; import net.minecraft.world.scores.Objective; -import net.minecraft.world.scores.PlayerScoreEntry; import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.Scoreboard; +//#if MC >= 12004 +import net.minecraft.network.chat.numbers.NumberFormat; +import net.minecraft.world.scores.PlayerScoreEntry; +//#else +//$$ import net.minecraft.world.scores.Score; +//#endif @UtilityClass public class ScoreboardHelper { @@ -39,17 +43,26 @@ public static ScoreboardState getScoreboardData() { return null; } + //#if MC >= 12004 Collection collection = scoreboard.listPlayerScores(objective); List list = collection.stream().filter(score -> !score.owner().startsWith("#")) .collect(Collectors.toList()); + //#else + //$$Collection collection = scoreboard.getPlayerScores(objective); + //$$List list = (List) collection.stream() + //$$ .filter(score -> (score.getOwner() != null && !score.getOwner().startsWith("#"))) + //$$ .collect(Collectors.toList()); + //#endif if (list.size() > 15) { collection = Lists.newArrayList(Iterables.skip(list, collection.size() - 15)); } else { collection = list; } - List> list2 = Lists.newArrayListWithCapacity(collection.size()); + Component title = objective.getDisplayName(); + //#if MC >= 12004 + List> list2 = Lists.newArrayListWithCapacity(collection.size()); for (PlayerScoreEntry score : collection) { PlayerTeam playerTeam2 = scoreboard.getPlayersTeam(score.owner()); Component component2 = PlayerTeam.formatNameForTeam(playerTeam2, score.ownerName()); @@ -60,10 +73,21 @@ public static ScoreboardState getScoreboardData() { component2)); } + //#else + //$$List> list2 = Lists.newArrayListWithCapacity(collection.size()); + //$$for (Score score : collection) { + //$$ PlayerTeam playerTeam2 = scoreboard.getPlayersTeam(score.getOwner()); + //$$ Component component2 = PlayerTeam.formatNameForTeam(playerTeam2, Component.literal(score.getOwner())); + //$$ list2.add(Pair.of(score.getScore(), component2)); + //$$} + //#endif return new ScoreboardState(title, list2); } + //#if MC >= 12004 public record ScoreboardState(Component title, List> entries) { } - + //#else + //$$public record ScoreboardState(Component title, List> entries) {} + //#endif }