Skip to content

Commit

Permalink
Continued work on converting configs over to being translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Aug 22, 2024
1 parent e2816f4 commit 877d8ff
Show file tree
Hide file tree
Showing 51 changed files with 2,190 additions and 435 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ public class AdditionsConfig extends BaseMekanismConfig {
}

private void addBabyTypeConfig(BabyType type, ModConfigSpec.Builder builder, Holder<EntityType<?>> entityTypeProvider, EntityType<?> parentType) {
spawnConfigs.put(type, new SpawnConfig(this, builder, "baby " + type.getSerializedName().replace('_', ' '),
entityTypeProvider, parentType));
spawnConfigs.put(type, new SpawnConfig(this, builder, "baby_" + type.getSerializedName(), entityTypeProvider, parentType));
}

@Override
Expand Down Expand Up @@ -116,7 +115,7 @@ private SpawnConfig(IMekanismConfig config, ModConfigSpec.Builder builder, Strin
this.parentType = parentType;
BabySpawnTranslations translations = BabySpawnTranslations.create(name);

translations.topLevel().applyToBuilder(builder).push(name.replace(" ", "-"));
translations.topLevel().applyToBuilder(builder).push(name);
this.shouldSpawn = CachedBooleanValue.wrap(config, translations.shouldSpawn().applyToBuilder(builder)
.worldRestart()
.define("shouldSpawn", true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import mekanism.additions.common.MekanismAdditions;
import mekanism.common.config.IConfigTranslation;
import mekanism.common.util.text.TextUtils;
import net.minecraft.Util;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -63,22 +64,26 @@ public record BabySpawnTranslations(
IConfigTranslation structureBlacklist
) {

public IConfigTranslation[] toArray() {
return new IConfigTranslation[]{topLevel, shouldSpawn, minSize, maxSize, weight, costPerEntity, maxCost, biomeBlacklist, structureBlacklist};
}

private static String getKey(String name, String path) {
name = name.replace(" ", "_");
return Util.makeDescriptionId("configuration", MekanismAdditions.rl("server.baby.spawning." + name + "." + path));
}

public static BabySpawnTranslations create(String name) {
public static BabySpawnTranslations create(String key) {
String name = TextUtils.formatAndCapitalize(key);
return new BabySpawnTranslations(
new ConfigTranslation(getKey(name, "top_level"), name, "Config options regarding " + name + "."),
new ConfigTranslation(getKey(name, "should_spawn"), "Should Spawn", "Enable the spawning of " + name + ". Think baby zombies."),
new ConfigTranslation(getKey(name, "min_size"), "Min Group Size", "The multiplier for minimum group size of " + name + " spawns, compared to the adult mob."),
new ConfigTranslation(getKey(name, "max_size"), "Max Group Size", "The multiplier for maximum group size of " + name + " spawns, compared to the adult mob."),
new ConfigTranslation(getKey(name, "weight"), "Weight Multiplier", "The multiplier for weight of " + name + " spawns, compared to the adult mob."),
new ConfigTranslation(getKey(name, "cost_per_entity"), "Cost Per Entity Multiplier", "The multiplier for spawn cost per entity of " + name + " spawns, compared to the adult mob."),
new ConfigTranslation(getKey(name, "max_cost"), "Max Cost Multiplier", "The multiplier for max spawn cost of " + name + " spawns, compared to the adult mob."),
new ConfigTranslation(getKey(name, "biome_blacklist"), "Biome Blacklist", "The list of biome ids that " + name + " will not spawn in even if the normal mob variant can spawn."),
new ConfigTranslation(getKey(name, "structure_blacklist"), "Structure Blacklist", "The list of structure ids that " + name + " will not spawn in even if the normal mob variant can spawn.")
new ConfigTranslation(getKey(key, "top_level"), name, "Config options regarding " + name + "."),
new ConfigTranslation(getKey(key, "should_spawn"), "Should Spawn", "Enable the spawning of " + name + ". Think baby zombies."),
new ConfigTranslation(getKey(key, "min_size"), "Min Group Size", "The multiplier for minimum group size of " + name + " spawns, compared to the adult mob."),
new ConfigTranslation(getKey(key, "max_size"), "Max Group Size", "The multiplier for maximum group size of " + name + " spawns, compared to the adult mob."),
new ConfigTranslation(getKey(key, "weight"), "Weight Multiplier", "The multiplier for weight of " + name + " spawns, compared to the adult mob."),
new ConfigTranslation(getKey(key, "cost_per_entity"), "Cost Per Entity Multiplier", "The multiplier for spawn cost per entity of " + name + " spawns, compared to the adult mob."),
new ConfigTranslation(getKey(key, "max_cost"), "Max Cost Multiplier", "The multiplier for max spawn cost of " + name + " spawns, compared to the adult mob."),
new ConfigTranslation(getKey(key, "biome_blacklist"), "Biome Blacklist", "The list of biome ids that " + name + " will not spawn in even if the normal mob variant can spawn."),
new ConfigTranslation(getKey(key, "structure_blacklist"), "Structure Blacklist", "The list of structure ids that " + name + " will not spawn in even if the normal mob variant can spawn.")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ private void addConfigs() {
addConfigs(MekanismAdditionsConfig.getConfigs());
addConfigs(AdditionsConfigTranslations.values());
for (BabyType type : BabyType.values()) {
BabySpawnTranslations translations = BabySpawnTranslations.create("baby " + type.getSerializedName().replace('_', ' '));
addConfigs(translations.topLevel(), translations.shouldSpawn(), translations.weight(), translations.minSize(), translations.maxSize(),
translations.costPerEntity(), translations.maxCost(), translations.biomeBlacklist(), translations.structureBlacklist());
addConfigs(BabySpawnTranslations.create("baby_" + type.getSerializedName()).toArray());
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/datagen/generated/mekanism/assets/mekanism/lang/en_au.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/datagen/generated/mekanism/assets/mekanism/lang/en_gb.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 877d8ff

Please sign in to comment.