From 9b6a8d4d8fa19a32474bbb8c78875ea4002595d1 Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Fri, 27 Aug 2021 18:00:19 +0300 Subject: CIT ordering --- src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java | 4 +++- src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main/java/shcm/shsupercm/fabric/citresewn') diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java b/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java index 0ecd632..76473a0 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java @@ -10,6 +10,7 @@ import net.minecraft.world.World; import shcm.shsupercm.fabric.citresewn.pack.cits.*; import java.util.*; +import java.util.stream.Collectors; public class ActiveCITs { public final Collection cits; @@ -21,7 +22,8 @@ public class ActiveCITs { public ActiveCITs(Collection cits) { this.cits = cits; - for (CIT cit : cits) { + + for (CIT cit : cits.stream().sorted(Comparator.comparingInt(cit -> cit.weight).reversed().thenComparing(cit -> cit.propertiesIdentifier.getPath())).collect(Collectors.toList())) { if (cit instanceof CITItem item) for (Item type : item.items) citItems.computeIfAbsent(type, t -> new ArrayList<>()).add(item); diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java index 2bd2b76..f50f6e9 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java @@ -39,7 +39,7 @@ public abstract class CIT { public final Predicate nbt; - private final int weight; + public final int weight; public CIT(CITPack pack, Identifier identifier, Properties properties) throws CITParseException { this.pack = pack; -- cgit