Skip to content

Commit

Permalink
Backport 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Jan 11, 2025
1 parent fab1173 commit 158097b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]
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/[email protected]
with:
Expand Down
1 change: 1 addition & 0 deletions settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"versions": [
"1.20.2-fabric",
"1.20.4-fabric",
"1.20.6-fabric",
"1.21-fabric",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<dev.tr7zw.exordium.components.vanilla.PlayerListComponent.PlayerListContext> {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -107,7 +116,11 @@ public List<Integer> 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;
}
}
Expand Down
32 changes: 28 additions & 4 deletions src/main/java/dev/tr7zw/exordium/util/ScoreboardHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -39,17 +43,26 @@ public static ScoreboardState getScoreboardData() {
return null;
}

//#if MC >= 12004
Collection<PlayerScoreEntry> collection = scoreboard.listPlayerScores(objective);
List<PlayerScoreEntry> list = collection.stream().filter(score -> !score.owner().startsWith("#"))
.collect(Collectors.toList());
//#else
//$$Collection<Score> collection = scoreboard.getPlayerScores(objective);
//$$List<Score> list = (List<Score>) 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<Pair<Component, Component>> list2 = Lists.newArrayListWithCapacity(collection.size());

Component title = objective.getDisplayName();
//#if MC >= 12004
List<Pair<Component, Component>> list2 = Lists.newArrayListWithCapacity(collection.size());
for (PlayerScoreEntry score : collection) {
PlayerTeam playerTeam2 = scoreboard.getPlayersTeam(score.owner());
Component component2 = PlayerTeam.formatNameForTeam(playerTeam2, score.ownerName());
Expand All @@ -60,10 +73,21 @@ public static ScoreboardState getScoreboardData() {
component2));

}
//#else
//$$List<Pair<Integer, Component>> 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<Pair<Component, Component>> entries) {
}

//#else
//$$public record ScoreboardState(Component title, List<Pair<Integer, Component>> entries) {}
//#endif
}

0 comments on commit 158097b

Please sign in to comment.