Skip to content

Commit

Permalink
Fix shard set sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed Dec 28, 2024
1 parent 925e401 commit 15a6d81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ authors=Falkreon, acikek
contributors=Trudle, Tomate0613, afamiliarquiet, FoundationGames, TheEpicBlock, hama
license=MIT
# Mod Version
baseVersion=1.8.2-rc.5
baseVersion=1.8.2-rc.6
# Branch Metadata
branch=1.21
tagBranch=1.21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,14 @@ public int layoutHeight() {
public void setShardSet(Identifier setId, ShardLibrary library, ShardCollection collection) {
List<Identifier> shardSet = new ArrayList<>(library.shardSets().get(setId));
shardSet.sort((a, b) -> {
int aPriority = library.shards().get(a)
.map(Shard::listOrder)
.orElseGet(() -> library.shards().get(a)
.map(Shard::shardTypeId)
.flatMap(library.shardTypes()::get)
.map(ShardType::listOrder))
int aPriority = library.shards().get(a).flatMap(shard ->
shard.listOrder()
.or(() -> library.shardTypes().get(shard.shardTypeId()).map(ShardType::listOrder)))
.orElse(Integer.MAX_VALUE);

int bPriority = library.shards().get(b)
.map(Shard::listOrder)
.orElseGet(() -> library.shards().get(b)
.map(Shard::shardTypeId)
.flatMap(library.shardTypes()::get)
.map(ShardType::listOrder))
int bPriority = library.shards().get(b).flatMap(shard ->
shard.listOrder()
.or(() -> library.shardTypes().get(shard.shardTypeId()).map(ShardType::listOrder)))
.orElse(Integer.MAX_VALUE);

return Integer.compare(aPriority, bPriority);
Expand Down

0 comments on commit 15a6d81

Please sign in to comment.