diff --git a/gradle.properties b/gradle.properties index 1f8c3c5..176ecb6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.debug=false # Version -mod_version=1.2.09 +mod_version=1.2.10 # Mod mod_id=zenith diff --git a/src/main/java/net/zepalesque/zenith/api/packconfig/PackConfig.java b/src/main/java/net/zepalesque/zenith/api/packconfig/PackConfig.java index 08c61e4..252f483 100644 --- a/src/main/java/net/zepalesque/zenith/api/packconfig/PackConfig.java +++ b/src/main/java/net/zepalesque/zenith/api/packconfig/PackConfig.java @@ -25,15 +25,21 @@ public class PackConfig { private final PackType type; private final HashMap, PackResources> resources = new HashMap<>(); private final String folder; + private final boolean hideInMenu; private boolean locked = false; - public PackConfig(ResourceLocation id, PackType type) { + public PackConfig(ResourceLocation id, PackType type, boolean hideInMenu) { this.id = id; this.type = type; this.folder = switch (type) { case SERVER_DATA -> "data/"; case CLIENT_RESOURCES -> "resource/"; }; + this.hideInMenu = hideInMenu; + } + + public PackConfig(ResourceLocation id, PackType type) { + this(id, type, true); } public ConfigAssembledPackResources.AssembledResourcesSupplier generate(Path path) { @@ -43,7 +49,7 @@ public ConfigAssembledPackResources.AssembledResourcesSupplier generate(Path pat } public PathPackResources createPack(String path, String id) { - Path resource = ModList.get().getModFileById(this.id.getNamespace()).getFile().findResource("packs/" + path + id); + Path resource = ModList.get().getModFileById(this.id.getNamespace()).getFile().findResource("packs/" + this.folder + path + id); PackLocationInfo loc = new PackLocationInfo(id, Component.empty(), PackSource.BUILT_IN, Optional.empty()); return new PathPackResources(loc, resource); } @@ -51,9 +57,9 @@ public PathPackResources createPack(String path, String id) { public > T register(T config, String path, String id, Predicate predicate) { if (!locked) { resources.putIfAbsent(() -> predicate.test(config.get()), createPack(path, id)); - Zenith.LOGGER.info("Registered config {}{} for pack {}...", path, id, this.id); + Zenith.LOGGER.info("Registered config {}{}{} for pack {}...", this.folder, path, id, this.id); } else { - Zenith.LOGGER.warn("Attempted to register pack config for pack {}{} after locking was already complete!", path, id); + Zenith.LOGGER.warn("Attempted to register config {}{}{} for pack {} after locking was already complete!", this.folder, path, id, this.id); } return config; } @@ -81,7 +87,7 @@ public > T register(T config, Strin public void setup(AddPackFindersEvent event) { if (event.getPackType() == this.type) { - PackUtils.setupPack(event, this.id, this.folder, true, this::generate); + PackUtils.setupPack(event, this.id, this.folder, true, this.hideInMenu, this::generate); } } } diff --git a/src/main/java/net/zepalesque/zenith/api/packconfig/PackUtils.java b/src/main/java/net/zepalesque/zenith/api/packconfig/PackUtils.java index 2930a7c..a68f57f 100644 --- a/src/main/java/net/zepalesque/zenith/api/packconfig/PackUtils.java +++ b/src/main/java/net/zepalesque/zenith/api/packconfig/PackUtils.java @@ -22,13 +22,12 @@ public class PackUtils { - public static void setupPack(AddPackFindersEvent event, String modid, String path, String id, boolean required, Function packBuilder) { + public static void setupPack(AddPackFindersEvent event, String modid, String path, String id, boolean required, boolean hidden, Function packBuilder) { PackLocationInfo loc = new PackLocationInfo(id, Component.translatable("pack." + modid + "." + id + ".title"), PackSource.BUILT_IN, Optional.empty()); - String folder = (event.getPackType() == PackType.SERVER_DATA ? "data/" : "resource/"); - Path resourcePath = ModList.get().getModFileById(modid).getFile().findResource("packs/" + folder + path); + Path resourcePath = ModList.get().getModFileById(modid).getFile().findResource("packs/" + path); PackMetadataSection metadata = new PackMetadataSection(Component.translatable("pack." + modid + "." + id + ".description"), SharedConstants.getCurrentVersion().getPackVersion(event.getPackType())); - Pack.Metadata meta = new Pack.Metadata(metadata.description(), PackCompatibility.COMPATIBLE, FeatureFlagSet.of(), List.of(), true); + Pack.Metadata meta = new Pack.Metadata(metadata.description(), PackCompatibility.COMPATIBLE, FeatureFlagSet.of(), List.of(), hidden); Pack.ResourcesSupplier resources = packBuilder.apply(resourcePath); event.addRepositorySource((source) -> source.accept(new Pack( @@ -40,12 +39,12 @@ public static void setupPack(AddPackFindersEvent event, String modid, String pat } - public static void setupPack(AddPackFindersEvent event, String modid, String path, String id, boolean required) { - setupPack(event, modid, path, id, required, PathPackResources.PathResourcesSupplier::new); + public static void setupPack(AddPackFindersEvent event, String modid, String path, String id, boolean required, boolean hidden) { + setupPack(event, modid, path, id, required, hidden, PathPackResources.PathResourcesSupplier::new); } - public static void setupPack(AddPackFindersEvent event, ResourceLocation location, String folder, boolean required, Function packBuilder) { + public static void setupPack(AddPackFindersEvent event, ResourceLocation location, String folder, boolean required, boolean hidden, Function packBuilder) { String path = location.getPath(); - setupPack(event, location.getNamespace(), folder + path, path, required, packBuilder); + setupPack(event, location.getNamespace(), folder + path, path, required, hidden, packBuilder); } }