Skip to content

Commit

Permalink
Make generated resources hidden again
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Jan 4, 2024
1 parent bdb2a33 commit 0c23908
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.server.packs.repository.Pack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jspecify.annotations.Nullable;

import java.io.IOException;
import java.nio.file.Files;
Expand All @@ -33,15 +34,15 @@ public class DynamicAssetGenerator {
public static final String SOURCE_JSON_DIR = MOD_ID +"/generators";
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);

public static PackMetadataSection fromCache(ResourceCache cache) {
public static PackMetadataSection makeMetadata(ResourceCache cache) {
return new PackMetadataSection(
Component.literal("Dynamic Asset Generator: " + cache.getName()),
Component.literal(DynamicAssetGenerator.MOD_ID + '/' + cache.getName()),
SharedConstants.getCurrentVersion().getPackVersion(cache.getPackType()),
Optional.empty()
);
}

private static ModConfig configs;
private static @Nullable ModConfig configs;

public static ModConfig getConfig() {
if (configs == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void listResources(@NonNull PackType packType, @NonNull String namespace,
@Override
public <T> T getMetadataSection(MetadataSectionSerializer<T> deserializer) {
if (deserializer.getMetadataSectionName().equals("pack")) {
return (T) DynamicAssetGenerator.fromCache(cache);
return (T) DynamicAssetGenerator.makeMetadata(cache);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ static void registerForType(PackType type) {
getInstance().packForType(type, consumer ->
DynamicAssetGenerator.CACHES.forEach(((location, info) -> {
if (info.cache().getPackType() == type) {
var metadata = DynamicAssetGenerator.fromCache(info.cache());
var metadata = DynamicAssetGenerator.makeMetadata(info.cache());
var packInfo = new Pack.Info(
metadata.description(),
PackCompatibility.COMPATIBLE,
FeatureFlagSet.of(),
List.of()
);
Pack pack = Pack.create(
DynamicAssetGenerator.MOD_ID+'/'+info.cache().getName().toString(),
Component.literal(info.cache().getName().toString()),
DynamicAssetGenerator.MOD_ID+'/'+ info.cache().getName(),
Component.literal(DynamicAssetGenerator.MOD_ID+'/'+ info.cache().getName()),
true,
new Pack.ResourcesSupplier() {
@Override
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ parchment_mappings = "2023.12.10"

neoforge = "20.4.48-beta"

fabric_loader = "0.14.24"
fabric_api = "0.91.3+1.20.4"
fabric_loader = "0.15.3"
fabric_api = "0.92.0+1.20.4"

mdg_plugin = "1.4.3"
mdg_dsl = "1.5.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void addResourcePack(AddPackFindersEvent event) {
DynamicAssetGenerator.CACHES.forEach((location, info) -> {
if (info.cache().getPackType() == type) {
event.addRepositorySource(consumer -> {
var metadata = DynamicAssetGenerator.fromCache(info.cache());
var metadata = DynamicAssetGenerator.makeMetadata(info.cache());
var packInfo = new Pack.Info(
metadata.description(),
PackCompatibility.COMPATIBLE,
Expand All @@ -35,8 +35,8 @@ public static void addResourcePack(AddPackFindersEvent event) {
true
);
Pack pack = Pack.create(
DynamicAssetGenerator.MOD_ID + ':' + info.cache().getName(),
Component.literal(info.cache().getName().toString()),
DynamicAssetGenerator.MOD_ID + '/' + info.cache().getName(),
Component.literal(DynamicAssetGenerator.MOD_ID+'/'+ info.cache().getName()),
true,
new Pack.ResourcesSupplier() {
@Override
Expand Down

0 comments on commit 0c23908

Please sign in to comment.