Skip to content

Commit

Permalink
Populate packs in a metapack under extended
Browse files Browse the repository at this point in the history
  • Loading branch information
duplexsystem committed Oct 25, 2024
1 parent 1912d8e commit 3d66386
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ public abstract class ModPlatform extends AbstractPlatform {
public void registerWorldTypes(BiConsumer<Identifier, WorldPreset> registerFunction) {
HashSet<String> configPacksInMetaPack = new HashSet<>();
getRawMetaConfigRegistry().forEach(pack -> {
PresetUtil.createMetaPackPreset(pack, this).apply(registerFunction);
PresetUtil.createMetaPackPreset(pack, this, false).apply(registerFunction);
pack.packs().forEach((k, v) -> configPacksInMetaPack.add(v.getID()));
});
getRawConfigRegistry()
.forEach(pack -> {
if(!configPacksInMetaPack.contains(pack.getID())) {
PresetUtil.createDefault(pack, this).apply(registerFunction);
}
PresetUtil.createDefault(pack, this, configPacksInMetaPack.contains(pack.getID())).apply(registerFunction);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@

public class PresetUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(PresetUtil.class);
private static final List<Identifier> PRESETS = new ArrayList<>();
private static final List<Pair<Identifier, Boolean>> PRESETS = new ArrayList<>();

public static Pair<Identifier, WorldPreset> createDefault(ConfigPack pack, ModPlatform platform) {
public static Pair<Identifier, WorldPreset> createDefault(ConfigPack pack, ModPlatform platform, boolean extended) {
Registry<DimensionType> dimensionTypeRegistry = platform.dimensionTypeRegistry();
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = platform.chunkGeneratorSettingsRegistry();
Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists =
Expand All @@ -51,7 +51,7 @@ public static Pair<Identifier, WorldPreset> createDefault(ConfigPack pack, ModPl
"terra:" + pack.getID().toLowerCase(Locale.ROOT) + "/" + pack.getNamespace().toLowerCase(
Locale.ROOT));

PRESETS.add(generatorID);
PRESETS.add(Pair.of(generatorID, extended));

HashMap<RegistryKey<DimensionOptions>, DimensionOptions> dimensionMap = new HashMap<>();

Expand All @@ -65,7 +65,7 @@ public static Pair<Identifier, WorldPreset> createDefault(ConfigPack pack, ModPl
return Pair.of(generatorID, preset);
}

public static Pair<Identifier, WorldPreset> createMetaPackPreset(MetaPack metaPack, ModPlatform platform) {
public static Pair<Identifier, WorldPreset> createMetaPackPreset(MetaPack metaPack, ModPlatform platform, boolean extended) {
Registry<DimensionType> dimensionTypeRegistry = platform.dimensionTypeRegistry();
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = platform.chunkGeneratorSettingsRegistry();
Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists =
Expand All @@ -75,7 +75,7 @@ public static Pair<Identifier, WorldPreset> createMetaPackPreset(MetaPack metaPa
metaPack.getID().toLowerCase(Locale.ROOT) + "/" + metaPack.getNamespace().toLowerCase(
Locale.ROOT));

PRESETS.add(generatorID);
PRESETS.add(Pair.of(generatorID, extended));

HashMap<RegistryKey<DimensionOptions>, DimensionOptions> dimensionMap = new HashMap<>();

Expand Down Expand Up @@ -187,7 +187,7 @@ private static void insertDefaults(Registry<DimensionType> dimensionTypeRegistry
}
}

public static List<Identifier> getPresets() {
public static List<Pair<Identifier, Boolean>> getPresets() {
return PRESETS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ public static void registerWorldPresetTags(Registry<WorldPreset> registry) {

PresetUtil
.getPresets()
.forEach(id -> MinecraftUtil
.getEntry(registry, id)
.forEach(pair -> MinecraftUtil
.getEntry(registry, pair.getLeft())
.ifPresentOrElse(
preset -> collect
.computeIfAbsent(WorldPresetTags.NORMAL, tag -> new ArrayList<>())
.add(preset),
() -> logger.error("Preset {} does not exist!", id)));
preset -> {
boolean useExtendedTag = pair.getRight(); // Get the boolean value from the pair
collect
.computeIfAbsent(useExtendedTag ? WorldPresetTags.EXTENDED : WorldPresetTags.NORMAL, tag -> new ArrayList<>())
.add(preset);
},
() -> logger.error("Preset {} does not exist!", pair.getLeft())));

registry.startTagReload(new RegistryTags<>(registry.getKey(), collect)).apply();


if(logger.isDebugEnabled()) {
registry.streamEntries()
.map(e -> e.registryKey().getValue() + ": " +
Expand Down

0 comments on commit 3d66386

Please sign in to comment.