@@ -80,48 +80,48 @@ public class SkyboxResourceHelper implements
8080 /*resourceManager;
8181 */ //?}
8282 return CompletableFuture .runAsync (() -> {
83- SkyboxManager .INSTANCE .clearSkyboxes ();
8483 if (Skyboxify .getConfig ().enabled .isEnabled ()) {
84+ SkyboxManager .INSTANCE .clearSkyboxes ();
8585 LOGGER .info ("Looking for OptiFine/MCPatcher Skies..." );
8686 theResourceManager .listPacks ().forEach (pack -> {
8787 final List <ResourceLocation > optifineSkies = new ArrayList <>();
88- pack .listResources (PackType .CLIENT_RESOURCES , ResourceLocation .DEFAULT_NAMESPACE , OPTIFINE_SKY_PARENT , (resourceLocation , inputStreamIoSupplier ) -> optifineSkies .add (resourceLocation ));
88+ pack .listResources (PackType .CLIENT_RESOURCES , ResourceLocation .DEFAULT_NAMESPACE , OPTIFINE_SKY_PARENT , filterResource (optifineSkies ));
89+ optifineSkies .sort (compareLocations (OPTIFINE_SKY_PATTERN ));
8990
9091 final List <ResourceLocation > mcpatcherSkies = new ArrayList <>();
91- pack .listResources (PackType .CLIENT_RESOURCES , ResourceLocation .DEFAULT_NAMESPACE , MCPATCHER_SKY_PARENT , (resourceLocation , inputStreamIoSupplier ) -> mcpatcherSkies .add (resourceLocation ));
92+ pack .listResources (PackType .CLIENT_RESOURCES , ResourceLocation .DEFAULT_NAMESPACE , MCPATCHER_SKY_PARENT , filterResource (mcpatcherSkies ));
93+ mcpatcherSkies .sort (compareLocations (MCPATCHER_SKY_PATTERN ));
9294
93- this .parseSkyboxes (pack , optifineSkies , mcpatcherSkies );
95+ Pattern skyPattern = OPTIFINE_SKY_PATTERN ;
96+ if (optifineSkies .isEmpty ()) {
97+ LOGGER .info ("Couldn't find any skies under \" optifine\" , searching for skies under \" mcpatcher\" instead..." );
98+ skyPattern = MCPATCHER_SKY_PATTERN ;
99+ }
100+
101+ this .parseSkyboxesInPack (pack , (skyPattern == OPTIFINE_SKY_PATTERN ? optifineSkies : mcpatcherSkies ), skyPattern );
94102 });
95103 }
96104 }).thenCompose (preparationBarrier ::wait );
97105 }
98106
107+ private static PackResources .ResourceOutput filterResource (final List <ResourceLocation > list ) {
108+ return (resourceLocation , streamIoSupplier ) -> {
109+ if (resourceLocation .getPath ().endsWith (".properties" )) {
110+ list .add (resourceLocation );
111+ }
112+ };
113+ }
114+
99115 //? <=1.21.8 {
100116 /*@Override
101117 public ResourceLocation getFabricId() {
102118 return Skyboxify.locationOrNull("skybox_reader");
103119 }
104120 */ //?}
105121
106- private void parseSkyboxes (final PackResources packResources , final List <ResourceLocation > optifineSkies , final List <ResourceLocation > mcpatcherSkies ) {
107- if (optifineSkies .isEmpty () && mcpatcherSkies .isEmpty ()) {
108- return ;
109- }
110-
111- Pattern skyPattern = OPTIFINE_SKY_PATTERN ;
112- List <ResourceLocation > skies = optifineSkies .stream ().filter (SkyboxResourceHelper ::isProperties ).sorted (compareLocations (skyPattern )).toList ();
113- if (optifineSkies .isEmpty ()) {
114- LOGGER .info ("Couldn't find any skies under \" optifine\" , searching for skies under \" mcpatcher\" instead..." );
115- skyPattern = MCPATCHER_SKY_PATTERN ;
116- skies = mcpatcherSkies .stream ().filter (SkyboxResourceHelper ::isProperties ).sorted (compareLocations (skyPattern )).toList ();
117- }
118-
119- if (!skies .isEmpty ()) {
120- this .parseSkyboxesInPack (packResources , skies , skyPattern );
121- }
122- }
123-
124122 private void parseSkyboxesInPack (final PackResources packResources , final List <ResourceLocation > skies , final Pattern skyPattern ) {
123+ if (skies .isEmpty ()) return ;
124+
125125 final Map <String , JsonArray > layers = new HashMap <>();
126126 skies .forEach (id -> {
127127 final Matcher matcher = skyPattern .matcher (id .getPath ());
@@ -196,8 +196,4 @@ private static Comparator<ResourceLocation> compareLocations(final Pattern patte
196196 return 0 ;
197197 });
198198 }
199-
200- private static boolean isProperties (final ResourceLocation location ) {
201- return location .getPath ().endsWith (".properties" );
202- }
203199}
0 commit comments