Skip to content

Commit 00ef7c8

Browse files
committed
Translation updates, lang file datagen
1 parent 002d0ee commit 00ef7c8

File tree

15 files changed

+394
-422
lines changed

15 files changed

+394
-422
lines changed

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ processTestResources {
316316
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
317317
}
318318

319+
compileDatagenJava {
320+
options.encoding = 'UTF-8'
321+
}
322+
319323
jar {
320324
from sourceSets.tunnels.output
321325
from sourceSets.main.output

src/api/java/dev/compactmods/machines/api/core/CMCommands.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import static dev.compactmods.machines.api.core.Constants.MOD_ID;
66

77
public class CMCommands {
8-
public static final ResourceLocation CMD_DIM_REGISTERED = new ResourceLocation(MOD_ID, "level_registered");
9-
public static final ResourceLocation CMD_DIM_NOT_FOUND = new ResourceLocation(MOD_ID, "level_not_found");
8+
public static final ResourceLocation LEVEL_REGISTERED = new ResourceLocation(MOD_ID, "level_registered");
9+
public static final ResourceLocation LEVEL_NOT_FOUND = new ResourceLocation(MOD_ID, "level_not_found");
10+
public static final ResourceLocation ROOM_DATA_NOT_FOUND = new ResourceLocation(MOD_ID, "room_data_not_found");
1011

1112
/**
1213
* Used for displaying the number of registered machines via summary commands.
@@ -17,4 +18,15 @@ public class CMCommands {
1718
* Used for displaying the number of registered rooms via summary commands.
1819
*/
1920
public static final ResourceLocation ROOM_REG_COUNT = new ResourceLocation(MOD_ID, "room_reg_count");
21+
public static final ResourceLocation NOT_A_MACHINE_BLOCK = new ResourceLocation(MOD_ID, "not_a_machine_block");
22+
public static final ResourceLocation MACHINE_NOT_BOUND = new ResourceLocation(MOD_ID, "machine_not_bound");
23+
public static final ResourceLocation REBIND_HAS_TUNNEL_CONNECTED = new ResourceLocation(MOD_ID, "rebind_tunnel_connected");
24+
25+
public static final ResourceLocation CMD_ROOM_NOT_REGISTERED = new ResourceLocation(MOD_ID, "room_not_registered");
26+
public static final ResourceLocation CMD_MACHINE_NOT_REGISTERED = new ResourceLocation(MOD_ID, "machine_not_registered");
27+
public static final ResourceLocation CMD_BAD_STATE = new ResourceLocation(MOD_ID, "incorrect_machine_state");
28+
public static final ResourceLocation NO_PLAYER_HISTORY = new ResourceLocation(MOD_ID, "no_player_history");
29+
public static final ResourceLocation WRONG_DIMENSION = new ResourceLocation(MOD_ID, "not_in_compact_dimension");
30+
public static final ResourceLocation NOT_IN_COMPACT_DIMENSION = new ResourceLocation(MOD_ID, "not_in_compact_dim");
31+
public static final ResourceLocation FAILED_CMD_FILE_ERROR = new ResourceLocation(MOD_ID, "failed_command_file_error");
2032
}

src/api/java/dev/compactmods/machines/api/core/Messages.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@
55
public abstract class Messages {
66
public static final ResourceLocation CANNOT_ENTER_MACHINE = new ResourceLocation(Constants.MOD_ID, "cannot_enter");
77
public static final ResourceLocation NO_MACHINE_DATA = new ResourceLocation(Constants.MOD_ID, "no_machine_data");
8-
public static final ResourceLocation MACHINE_SPAWNPOINT_SET = new ResourceLocation(Constants.MOD_ID, "spawnpoint_set");
8+
public static final ResourceLocation ROOM_SPAWNPOINT_SET = new ResourceLocation(Constants.MOD_ID, "spawnpoint_set");
99
public static final ResourceLocation TELEPORT_OUT_OF_BOUNDS = new ResourceLocation(Constants.MOD_ID, "teleport_oob");
1010
public static final ResourceLocation HOW_DID_YOU_GET_HERE = new ResourceLocation(Constants.MOD_ID, "how_did_you_get_here");
11-
public static final ResourceLocation NOT_IN_COMPACT_DIMENSION = new ResourceLocation(Constants.MOD_ID, "not_in_compact_dim");
1211
public static final ResourceLocation UNKNOWN_TUNNEL = new ResourceLocation(Constants.MOD_ID, "unknown_tunnel_type");
1312
public static final ResourceLocation NO_TUNNEL_SIDE = new ResourceLocation(Constants.MOD_ID, "no_available_sides");
14-
public static final ResourceLocation FAILED_CMD_FILE_ERROR = new ResourceLocation(Constants.MOD_ID, "failed_command_file_error");
13+
public static final ResourceLocation UNKNOWN_ROOM_CHUNK = new ResourceLocation(Constants.MOD_ID, "unknown_room_chunk");
14+
public static final ResourceLocation UNREGISTERED_CM_DIM = new ResourceLocation(Constants.MOD_ID, "dimension_not_registered");
15+
public static final ResourceLocation NEW_MACHINE = new ResourceLocation(Constants.MOD_ID, "new_machine");
16+
17+
/**
18+
* Used to show information about a player inside a Compact room.
19+
*/
20+
public static final ResourceLocation PLAYER_ROOM_INFO = new ResourceLocation(Constants.MOD_ID, "player_room_info");
21+
22+
/**
23+
* Used to show information about a room, accessed via a bound machine.
24+
*/
25+
public static final ResourceLocation MACHINE_ROOM_INFO = new ResourceLocation(Constants.MOD_ID, "machine_room_info");
1526
}

src/api/java/dev/compactmods/machines/api/core/Tooltips.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
public abstract class Tooltips {
66

77
public static final ResourceLocation UNKNOWN_PLAYER_NAME = new ResourceLocation(Constants.MOD_ID, "unknown_player");
8+
public static final ResourceLocation TUNNEL_TYPE = new ResourceLocation(Constants.MOD_ID, "tunnel_type");
9+
public static final ResourceLocation UNKNOWN_TUNNEL_TYPE = new ResourceLocation(Constants.MOD_ID, "unknown_tunnel_type");
810

911
public static abstract class Machines {
1012
public static final ResourceLocation ID = new ResourceLocation(Constants.MOD_ID, "machine.id");
1113
public static final ResourceLocation OWNER = new ResourceLocation(Constants.MOD_ID, "machine.owner");
1214
public static final ResourceLocation SIZE = new ResourceLocation(Constants.MOD_ID, "machine.size");
15+
public static final ResourceLocation BOUND_TO = new ResourceLocation(Constants.MOD_ID, "machine.bound_to");
1316
}
1417

1518
//#region Hints and Details
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package dev.compactmods.machines.datagen;
2+
3+
import dev.compactmods.machines.datagen.lang.BaseLangGenerator;
4+
import dev.compactmods.machines.i18n.TranslationUtil;
5+
import net.minecraft.resources.ResourceLocation;
6+
7+
public class AdvancementLangBuilder {
8+
9+
10+
private final BaseLangGenerator provider;
11+
private final ResourceLocation advancement;
12+
13+
public AdvancementLangBuilder(BaseLangGenerator add, ResourceLocation adv) {
14+
this.provider = add;
15+
this.advancement = adv;
16+
}
17+
18+
public AdvancementLangBuilder title(String title) {
19+
provider.add(TranslationUtil.advId(advancement), title);
20+
return this;
21+
}
22+
23+
public AdvancementLangBuilder description(String description) {
24+
provider.add(TranslationUtil.advId(advancement) + ".desc", description);
25+
return this;
26+
}
27+
28+
public AdvancementLangBuilder noDesc() {
29+
return description("");
30+
}
31+
}

src/datagen/java/dev/compactmods/machines/datagen/DataGeneration.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package dev.compactmods.machines.datagen;
22

3-
import java.io.IOException;
43
import dev.compactmods.machines.CompactMachines;
4+
import dev.compactmods.machines.datagen.lang.BaseLangGenerator;
5+
import dev.compactmods.machines.datagen.lang.EnglishLangGenerator;
6+
import dev.compactmods.machines.datagen.lang.RussianLangGenerator;
57
import net.minecraft.data.DataGenerator;
68
import net.minecraftforge.common.data.ExistingFileHelper;
79
import net.minecraftforge.eventbus.api.SubscribeEvent;
@@ -12,22 +14,24 @@
1214
public class DataGeneration {
1315

1416
@SubscribeEvent
15-
public static void gatherData(GatherDataEvent event) throws IOException {
17+
public static void gatherData(GatherDataEvent event) {
1618
if (event.includeServer())
1719
registerServerProviders(event.getGenerator(), event);
1820

1921
if (event.includeClient())
2022
registerClientProviders(event.getGenerator(), event);
2123
}
2224

23-
private static void registerServerProviders(DataGenerator generator, GatherDataEvent event) throws IOException {
25+
private static void registerServerProviders(DataGenerator generator, GatherDataEvent event) {
2426
ExistingFileHelper helper = event.getExistingFileHelper();
2527
generator.addProvider(new LevelBiomeGenerator(generator));
26-
2728
generator.addProvider(new BlockLootGenerator(generator));
2829
generator.addProvider(new RecipeGenerator(generator));
2930
generator.addProvider(new AdvancementGenerator(generator));
3031
generator.addProvider(new TagGenerator(generator, helper));
32+
33+
generator.addProvider(new EnglishLangGenerator(generator));
34+
generator.addProvider(new RussianLangGenerator(generator));
3135
}
3236

3337
private static void registerClientProviders(DataGenerator generator, GatherDataEvent event) {
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package dev.compactmods.machines.datagen.lang;
2+
3+
import dev.compactmods.machines.CompactMachines;
4+
import dev.compactmods.machines.api.core.Advancements;
5+
import dev.compactmods.machines.api.core.CMCommands;
6+
import dev.compactmods.machines.api.core.Messages;
7+
import dev.compactmods.machines.api.core.Tooltips;
8+
import dev.compactmods.machines.api.tunnels.TunnelDefinition;
9+
import dev.compactmods.machines.core.Registration;
10+
import dev.compactmods.machines.core.Tunnels;
11+
import dev.compactmods.machines.datagen.AdvancementLangBuilder;
12+
import dev.compactmods.machines.i18n.TranslationUtil;
13+
import dev.compactmods.machines.machine.CompactMachineBlock;
14+
import dev.compactmods.machines.room.RoomSize;
15+
import net.minecraft.core.Direction;
16+
import net.minecraft.data.DataGenerator;
17+
import net.minecraft.resources.ResourceLocation;
18+
import net.minecraftforge.common.data.LanguageProvider;
19+
20+
import static org.apache.commons.lang3.StringUtils.capitalize;
21+
22+
public abstract class BaseLangGenerator extends LanguageProvider {
23+
24+
private final String locale;
25+
26+
public BaseLangGenerator(DataGenerator gen, String locale) {
27+
super(gen, CompactMachines.MOD_ID, locale);
28+
this.locale = locale;
29+
}
30+
31+
protected abstract String getSizeTranslation(RoomSize size);
32+
33+
@SuppressWarnings("unused")
34+
protected String getDirectionTranslation(Direction dir) {
35+
return dir.getSerializedName();
36+
}
37+
38+
protected String getMachineTranslation() {
39+
return "Compact Machine";
40+
}
41+
42+
@Override
43+
protected void addTranslations() {
44+
// Machine Block names
45+
for(var size : RoomSize.values()) {
46+
add(CompactMachineBlock.getBySize(size), String.format("%s (%s)", getMachineTranslation(), getSizeTranslation(size)));
47+
}
48+
49+
// Direction Names
50+
for (var dir : Direction.values()) {
51+
add(CompactMachines.MOD_ID + ".direction." + dir.name(), getDirectionTranslation(dir));
52+
}
53+
}
54+
55+
protected void addTooltip(ResourceLocation id, String translation) {
56+
add(TranslationUtil.tooltipId(id), translation);
57+
}
58+
59+
protected void addTunnel(TunnelDefinition tunnel, String name) {
60+
add(TranslationUtil.tunnelId(tunnel.getRegistryName()), name);
61+
}
62+
63+
protected void addAdvancementTranslations() {
64+
advancement(Advancements.FOUNDATIONS)
65+
.title("Foundations")
66+
.description("Obtain a breakable wall block.");
67+
68+
advancement(Advancements.CLAIMED_GIANT_MACHINE)
69+
.title("Got Enough Space?")
70+
.description("Claim a giant compact machine.");
71+
72+
advancement(Advancements.CLAIMED_LARGE_MACHINE)
73+
.title("Room to Grow")
74+
.description("Claim a large compact machine.");
75+
76+
advancement(Advancements.CLAIMED_MAX_MACHINE)
77+
.title("Room for Activities!")
78+
.description("Claim a maximum compact machine.");
79+
80+
advancement(Advancements.CLAIMED_NORMAL_MACHINE)
81+
.title("Bigger on the Inside")
82+
.description("Claim a normal compact machine.");
83+
84+
advancement(Advancements.CLAIMED_SMALL_MACHINE)
85+
.title("I Can Breathe")
86+
.description("Claim a small compact machine.");
87+
88+
advancement(Advancements.CLAIMED_TINY_MACHINE)
89+
.title("Small Spaces, Big Ideas")
90+
.description("Claim a tiny compact machine.");
91+
92+
advancement(Advancements.GOT_SHRINKING_DEVICE)
93+
.title("Personal Shrinking Device")
94+
.description("Obtain a Personal Shrinking Device");
95+
96+
advancement(Advancements.HOW_DID_YOU_GET_HERE)
97+
.title("How Did You Get Here?!")
98+
.description("Which machine is the player in?!");
99+
100+
advancement(Advancements.ROOT).title("Compact Machines").noDesc();
101+
}
102+
103+
protected AdvancementLangBuilder advancement(ResourceLocation advancement) {
104+
return new AdvancementLangBuilder(this, advancement);
105+
}
106+
107+
protected void addCommand(ResourceLocation id, String translation) {
108+
this.add(TranslationUtil.commandId(id), translation);
109+
}
110+
111+
protected void addMessage(ResourceLocation id, String translation) {
112+
this.add(TranslationUtil.messageId(id), translation);
113+
}
114+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package dev.compactmods.machines.datagen.lang;
2+
3+
import dev.compactmods.machines.CompactMachines;
4+
import dev.compactmods.machines.api.core.CMCommands;
5+
import dev.compactmods.machines.api.core.Messages;
6+
import dev.compactmods.machines.api.core.Tooltips;
7+
import dev.compactmods.machines.core.Registration;
8+
import dev.compactmods.machines.core.Tunnels;
9+
import dev.compactmods.machines.room.RoomSize;
10+
import net.minecraft.data.DataGenerator;
11+
12+
import static org.apache.commons.lang3.StringUtils.capitalize;
13+
14+
public class EnglishLangGenerator extends BaseLangGenerator {
15+
public EnglishLangGenerator(DataGenerator gen) {
16+
super(gen, "en_us");
17+
}
18+
19+
@Override
20+
protected void addTranslations() {
21+
super.addTranslations();
22+
23+
addMessage(Messages.CANNOT_ENTER_MACHINE, "You fumble with the shrinking device, to no avail. It refuses to work.");
24+
addMessage(Messages.NO_MACHINE_DATA, "No machine data loaded; report this.");
25+
addMessage(Messages.ROOM_SPAWNPOINT_SET, "New spawn point set.");
26+
addMessage(Messages.HOW_DID_YOU_GET_HERE, "How did you get here?!");
27+
addMessage(Messages.NEW_MACHINE, "New Machine");
28+
addMessage(Messages.TELEPORT_OUT_OF_BOUNDS, "An otherworldly force prevents your teleportation.");
29+
addMessage(Messages.NO_TUNNEL_SIDE, "There are no available sides for this tunnel type.");
30+
31+
// 1 = Display Name, 2 = Chunk, 3 = Size
32+
addMessage(Messages.PLAYER_ROOM_INFO, "Player '%1$s' is inside a %3$s room at %2$s.");
33+
addMessage(Messages.MACHINE_ROOM_INFO, "Machine at %1$s is bound to a %2$s size room at %3$s");
34+
35+
addCommand(CMCommands.NOT_IN_COMPACT_DIMENSION, "Cannot use that command outside of a machine room.");
36+
addCommand(CMCommands.FAILED_CMD_FILE_ERROR, "Failed to execute command; there was a file error. Check logs.");
37+
addCommand(CMCommands.MACHINE_NOT_BOUND, "Machine at %s does not have an associated ID.");
38+
addCommand(CMCommands.ROOM_REG_COUNT, "Number of registered machine blocks: %s");
39+
addCommand(CMCommands.LEVEL_REGISTERED, "Compact Machine dimension found.");
40+
addCommand(CMCommands.LEVEL_NOT_FOUND, "Compact Machine dimension could not be found.");
41+
addCommand(CMCommands.CMD_ROOM_NOT_REGISTERED, "");
42+
addCommand(CMCommands.ROOM_DATA_NOT_FOUND, "");
43+
44+
addAdvancementTranslations();
45+
46+
add(Registration.BLOCK_BREAKABLE_WALL.get(), "Compact Machine Wall");
47+
add(Registration.BLOCK_SOLID_WALL.get(), "Solid Compact Machine Wall");
48+
add(Tunnels.BLOCK_TUNNEL_WALL.get(), "Solid Compact Machine Wall (with Tunnel)");
49+
50+
add(Registration.PERSONAL_SHRINKING_DEVICE.get(), "Personal Shrinking Device");
51+
52+
add(CompactMachines.MOD_ID + ".direction.side", "Side: %s");
53+
add(CompactMachines.MOD_ID + ".connected_block", "Connected: %s");
54+
55+
addTunnel(Tunnels.ITEM_TUNNEL_DEF.get(), "Item Tunnel");
56+
addTunnel(Tunnels.FLUID_TUNNEL_DEF.get(), "Fluid Tunnel");
57+
addTunnel(Tunnels.FORGE_ENERGY.get(), "Energy Tunnel");
58+
// addTunnel(Tunnels.REDSTONE_IN_DEF.get(), "Redstone Tunnel (In)");
59+
// addTunnel(Tunnels.REDSTONE_OUT_DEF.get(), "Redstone Tunnel (Out)");
60+
61+
addTooltip(Tooltips.Details.PERSONAL_SHRINKING_DEVICE, "Used as in-game documentation and to enter Compact Machines.");
62+
addTooltip(Tooltips.Details.SOLID_WALL, "Warning! Unbreakable for non-creative players!");
63+
64+
addTooltip(Tooltips.HINT_HOLD_SHIFT, "Hold shift for details.");
65+
addTooltip(Tooltips.UNKNOWN_PLAYER_NAME, "Unknown Player");
66+
67+
addTooltip(Tooltips.Machines.ID, "Machine #%s");
68+
addTooltip(Tooltips.Machines.OWNER, "Owner: %s");
69+
addTooltip(Tooltips.Machines.SIZE, "Internal Size: %1$sx%1$sx%1$s");
70+
addTooltip(Tooltips.Machines.BOUND_TO, "Bound to: %1$s");
71+
72+
addTooltip(Tooltips.TUNNEL_TYPE, "Type ID: %1$s");
73+
addTooltip(Tooltips.UNKNOWN_TUNNEL_TYPE, "Unknown Tunnel Type (%s)");
74+
75+
add("itemGroup." + CompactMachines.MOD_ID, "Compact Machines");
76+
77+
add("compactmachines.psd.pages.machines.title", "Compact Machines");
78+
add("compactmachines.psd.pages.machines", "Compact Machines are the core mechanic of this mod. They allow you to build large " +
79+
"rooms in a single block space connected to the outside world. They come in various sizes ranging from 3x3x3 to 13x13x13.\n\n" +
80+
"You can use Tunnels to connect the outside block faces with any of the inside walls to transport items, fluids etc.\n\n" +
81+
"You can enter a Compact Machine by right-clicking it with a Personal Shrinking Device. Please use JEI to look up crafting recipes.");
82+
83+
add("jei.compactmachines.machines", "Machines are used to make pocket dimensions. Craft a machine and place it in world, then use a Personal Shrinking Device to go inside.");
84+
add("jei.compactmachines.shrinking_device", "Use the Personal Shrinking Device (PSD) on a machine in order to enter a compact space. " +
85+
"You can also right click it in the overworld for more info.");
86+
}
87+
88+
@Override
89+
protected String getSizeTranslation(RoomSize size) {
90+
return capitalize(size.getSerializedName());
91+
}
92+
}

0 commit comments

Comments
 (0)