Skip to content

Commit

Permalink
Tips small refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Apr 7, 2024
1 parent 02374c9 commit 2a67848
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ dependencies {
runtimeOnly fg.deobf("mezz.jei:jei-$minecraft_version-forge:$jei_version")

compileOnly fg.deobf("dev.emi:emi-forge:$emi_version+$minecraft_version:api")
runtimeOnly fg.deobf("dev.emi:emi-forge:$emi_version+$minecraft_version")
//runtimeOnly fg.deobf("dev.emi:emi-forge:$emi_version+$minecraft_version")

compileOnly fg.deobf("vazkii.patchouli:Patchouli:$patchouli_version:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:$patchouli_version")
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/mods/railcraft/Translations.java
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,13 @@ public static class Subtitle {
public static final String MACHINE_ZAP = makeKey("subtitle", "machine.zap");
}

public static class Season {
public static final String DEFAULT = makeKey("season", "default");
public static final String HALLOWEEN = makeKey("season", "halloween");
public static final String CHRISTMAS = makeKey("season", "christmas");
public static final String NONE = makeKey("season", "none");
}

public static class DamageSource {
public static final List<String> BORE = IntStream.rangeClosed(1, 6)
.mapToObj(i -> makeKey("death", "bore." + i)).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ private void tipsTranslations() {
this.add(Translations.Tips.CROWBAR_LINK_STARTED, "Started Linking Carts");
this.add(Translations.Tips.CROWBAR_SEASON_DESC, "Current season:");

this.add(Season.NONE.getTranslationKey(), "None");
this.add(Season.DEFAULT.getTranslationKey(), "Default");
this.add(Season.CHRISTMAS.getTranslationKey(), "Christmas");
this.add(Season.HALLOWEEN.getTranslationKey(), "Halloween");
this.add(Translations.Season.NONE, "None");
this.add(Translations.Season.DEFAULT, "Default");
this.add(Translations.Season.CHRISTMAS, "Christmas");
this.add(Translations.Season.HALLOWEEN, "Halloween");

this.add(Translations.Tips.SIGNAL_LABEL_DESC1, "- Rename in Anvil -");
this.add(Translations.Tips.SIGNAL_LABEL_DESC2,
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/mods/railcraft/season/Season.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,23 @@

public enum Season implements StringRepresentable {

DEFAULT("default"),
HALLOWEEN("halloween"),
CHRISTMAS("christmas"),
NONE("none");
DEFAULT(Translations.Season.DEFAULT),
HALLOWEEN(Translations.Season.HALLOWEEN),
CHRISTMAS(Translations.Season.CHRISTMAS),
NONE(Translations.Season.NONE);

private static final StringRepresentable.EnumCodec<Season> CODEC =
StringRepresentable.fromEnum(Season::values);
private final String name;
private final String translationKey;

Season(String name) {
this.name = name;
Season(String translationKey) {
this.translationKey = translationKey;
this.name = translationKey.substring(translationKey.lastIndexOf('.') + 1);
}

public Component getDisplayName() {
return Component.translatable(this.getTranslationKey());
}

public String getTranslationKey() {
return Translations.makeKey("season", this.name);
return Component.translatable(this.translationKey);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,17 +808,19 @@ public final void setSecondaryColor(DyeColor color) {
*/
public enum Mode implements StringRepresentable {

SHUTDOWN("shutdown"),
IDLE("idle"),
RUNNING("running");
SHUTDOWN(Translations.Screen.LOCOMOTIVE_MODE_SHUTDOWN),
IDLE(Translations.Screen.LOCOMOTIVE_MODE_IDLE),
RUNNING(Translations.Screen.LOCOMOTIVE_MODE_RUNNING);

private static final StringRepresentable.EnumCodec<Mode> CODEC =
StringRepresentable.fromEnum(Mode::values);

private final String name;
private final String translationKey;

Mode(String name) {
this.name = name;
Mode(String translationKey) {
this.translationKey = translationKey;
this.name = translationKey.substring(translationKey.lastIndexOf('.') + 1);
}

public Mode next() {
Expand All @@ -835,11 +837,7 @@ public String getSerializedName() {
}

public Component getDisplayName() {
return Component.translatable(this.getTranslationKey());
}

public String getTranslationKey() {
return Translations.makeKey("screen", "locomotive.mode." + this.name);
return Component.translatable(this.translationKey);
}

public static Mode fromName(String name) {
Expand Down

0 comments on commit 2a67848

Please sign in to comment.