aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm/shsupercm/fabric
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-01-04 18:43:27 +0200
committerSHsuperCM <shsupercm@gmail.com>2022-01-04 18:43:27 +0200
commite790717a6fbad39f8643683a64df988dbda9ecd5 (patch)
treed8ba3a0b31bff8405e31291d6fcd9412d28ea029 /src/main/java/shcm/shsupercm/fabric
parent9cf2e864876072664be280063a2c15466cf35d4c (diff)
downloadCITResewn-e790717a6fbad39f8643683a64df988dbda9ecd5.tar.gz
CITResewn-e790717a6fbad39f8643683a64df988dbda9ecd5.tar.bz2
CITResewn-e790717a6fbad39f8643683a64df988dbda9ecd5.zip
Cleaned up cit root and fapi usage
Diffstat (limited to 'src/main/java/shcm/shsupercm/fabric')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITParser.java45
1 files changed, 13 insertions, 32 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITParser.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITParser.java
index 7e5ff5d..2872c48 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITParser.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/CITParser.java
@@ -1,7 +1,6 @@
package shcm.shsupercm.fabric.citresewn.pack;
import net.fabricmc.fabric.impl.resource.loader.GroupResourcePack;
-import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
@@ -49,31 +48,23 @@ public final class CITParser { private CITParser() {}
* @return a collection of CITPacks or an empty collection if resourcepack contains none
*/
public static Collection<CITPack> parse(ResourcePack resourcePack) {
- if (FabricLoader.getInstance().isModLoaded("fabric-resource-loader-v0")) {
- Collection<CITPack> group = parseFabricGroup(resourcePack);
- if (group != null)
- return group;
- }
+ if (resourcePack instanceof GroupResourcePack)
+ return ((GroupResourcePackAccessor) resourcePack).getPacks().stream()
+ .map(CITParser::parse)
+ .flatMap(Collection::stream)
+ .collect(Collectors.toList());
final CITPack citPack = new CITPack(resourcePack);
Collection<Identifier> packProperties = new ArrayList<>();
- for (String namespace : resourcePack.getNamespaces(ResourceType.CLIENT_RESOURCES)) {
- if (!Identifier.isValid(namespace))
- continue;
-
- packProperties.addAll(resourcePack.findResources(ResourceType.CLIENT_RESOURCES, namespace, "citresewn/cit", Integer.MAX_VALUE - 53, s -> s.endsWith(".properties")));
- if (resourcePack.contains(ResourceType.CLIENT_RESOURCES, new Identifier(namespace, "citresewn/cit.properties")))
- packProperties.add(new Identifier(namespace, "citresewn/cit.properties"));
-
- packProperties.addAll(resourcePack.findResources(ResourceType.CLIENT_RESOURCES, namespace, "optifine/cit", Integer.MAX_VALUE - 53, s -> s.endsWith(".properties")));
- if (resourcePack.contains(ResourceType.CLIENT_RESOURCES, new Identifier(namespace, "optifine/cit.properties")))
- packProperties.add(new Identifier(namespace, "optifine/cit.properties"));
-
- packProperties.addAll(resourcePack.findResources(ResourceType.CLIENT_RESOURCES, namespace, "mcpatcher/cit", Integer.MAX_VALUE - 53, s -> s.endsWith(".properties")));
- if (resourcePack.contains(ResourceType.CLIENT_RESOURCES, new Identifier(namespace, "mcpatcher/cit.properties")))
- packProperties.add(new Identifier(namespace, "mcpatcher/cit.properties"));
- }
+ for (String namespace : resourcePack.getNamespaces(ResourceType.CLIENT_RESOURCES))
+ if (Identifier.isValid(namespace))
+ for (String citRoot : new String[] { "citresewn", "optifine", "mcpatcher" }) {
+ packProperties.addAll(resourcePack.findResources(ResourceType.CLIENT_RESOURCES, namespace, citRoot + "/cit", Integer.MAX_VALUE - 53, s -> s.endsWith(".properties")));
+ Identifier global = new Identifier(namespace, citRoot + "/cit.properties");
+ if (resourcePack.contains(ResourceType.CLIENT_RESOURCES, global))
+ packProperties.add(global);
+ }
boolean readGlobalProperties = false;
for (Iterator<Identifier> iterator = packProperties.iterator(); iterator.hasNext(); ) {
@@ -120,16 +111,6 @@ public final class CITParser { private CITParser() {}
}
}
- public static Collection<CITPack> parseFabricGroup(ResourcePack resourcePack) {
- if (!(resourcePack instanceof GroupResourcePack))
- return null;
-
- return ((GroupResourcePackAccessor) resourcePack).getPacks().stream()
- .map(CITParser::parse)
- .flatMap(Collection::stream)
- .collect(Collectors.toList());
- }
-
public interface CITConstructor {
CIT cit(CITPack pack, Identifier identifier, Properties properties) throws CITParseException;
}