From 15a6d817a4577c34c6ac880c91e0f20e5d64afc0 Mon Sep 17 00:00:00 2001 From: zbx1425 Date: Sat, 28 Dec 2024 13:48:07 +0800 Subject: [PATCH] Fix shard set sorting --- gradle.properties | 2 +- .../client/screen/widget/WShardSetPanel.java | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index d175250..297020b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/net/modfest/scatteredshards/client/screen/widget/WShardSetPanel.java b/src/main/java/net/modfest/scatteredshards/client/screen/widget/WShardSetPanel.java index 5dac530..55390fa 100644 --- a/src/main/java/net/modfest/scatteredshards/client/screen/widget/WShardSetPanel.java +++ b/src/main/java/net/modfest/scatteredshards/client/screen/widget/WShardSetPanel.java @@ -55,20 +55,14 @@ public int layoutHeight() { public void setShardSet(Identifier setId, ShardLibrary library, ShardCollection collection) { List 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);