Skip to content

Commit

Permalink
Add translations for world config, and ensure all our enum based conf…
Browse files Browse the repository at this point in the history
…ig values have nice translations for the config GUI
  • Loading branch information
pupnewfster committed Aug 22, 2024
1 parent 877d8ff commit 49a5b9b
Show file tree
Hide file tree
Showing 57 changed files with 762 additions and 152 deletions.
2 changes: 1 addition & 1 deletion src/additions/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license="MIT"
authors="Aidancbrady, Thommy101, Thiakil, pupnewfster, dizzyd"
credits="unpairedbracket, CyanideX, Ridanisaurus and many others"
logoFile="logo.png"
description='''Additions module for Mekanism, contains things that don't quite fit in the other modules.'''
description='''Additions module for Mekanism, contains miscellaneous things that do not thematically fit in the other modules.'''

[[dependencies.mekanismadditions]]
modId="mekanism"
Expand Down
2 changes: 1 addition & 1 deletion src/api/java/mekanism/api/MekanismAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private MekanismAPI() {
/**
* The version of the api classes - may not always match the mod's version
*/
public static final String API_VERSION = "10.7.1";
public static final String API_VERSION = "10.7.3";
/**
* Mekanism's Mod ID
*/
Expand Down
2 changes: 1 addition & 1 deletion src/api/java/mekanism/api/MekanismAPITags.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private Chemicals() {
/**
* Chemicals in this tag cannot be inserted into framed blocks
*
* @since 10.7.1
* @since 10.7.3
*/
public static final TagKey<Chemical> FRAMEDBLOCKS_BLACKLISTED = tag("framedblocks_blacklisted");

Expand Down
4 changes: 2 additions & 2 deletions src/api/java/mekanism/api/RelativeSide.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.function.IntFunction;
import mekanism.api.annotations.NothingNullByDefault;
import mekanism.api.text.APILang;
import mekanism.api.text.IHasTranslationKey;
import mekanism.api.text.IHasTranslationKey.IHasEnumNameTranslationKey;
import mekanism.api.text.ILangEntry;
import net.minecraft.core.Direction;
import net.minecraft.network.codec.ByteBufCodecs;
Expand All @@ -15,7 +15,7 @@
import net.minecraft.util.StringRepresentable;

@NothingNullByDefault
public enum RelativeSide implements IHasTranslationKey, StringRepresentable {
public enum RelativeSide implements IHasEnumNameTranslationKey, StringRepresentable {
FRONT(APILang.FRONT),
LEFT(APILang.LEFT),
RIGHT(APILang.RIGHT),
Expand Down
4 changes: 2 additions & 2 deletions src/api/java/mekanism/api/Upgrade.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import mekanism.api.annotations.NothingNullByDefault;
import mekanism.api.text.APILang;
import mekanism.api.text.EnumColor;
import mekanism.api.text.IHasTranslationKey;
import mekanism.api.text.IHasTranslationKey.IHasEnumNameTranslationKey;
import mekanism.api.text.ILangEntry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
Expand All @@ -25,7 +25,7 @@
import org.jetbrains.annotations.Nullable;

@NothingNullByDefault
public enum Upgrade implements IHasTranslationKey, StringRepresentable {
public enum Upgrade implements IHasEnumNameTranslationKey, StringRepresentable {
SPEED("speed", APILang.UPGRADE_SPEED, APILang.UPGRADE_SPEED_DESCRIPTION, 8, EnumColor.RED),
ENERGY("energy", APILang.UPGRADE_ENERGY, APILang.UPGRADE_ENERGY_DESCRIPTION, 8, EnumColor.BRIGHT_GREEN),
FILTER("filter", APILang.UPGRADE_FILTER, APILang.UPGRADE_FILTER_DESCRIPTION, 1, EnumColor.DARK_AQUA),
Expand Down
4 changes: 2 additions & 2 deletions src/api/java/mekanism/api/security/SecurityMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import mekanism.api.annotations.NothingNullByDefault;
import mekanism.api.text.APILang;
import mekanism.api.text.EnumColor;
import mekanism.api.text.IHasTextComponent;
import mekanism.api.text.IHasTextComponent.IHasEnumNameTextComponent;
import mekanism.api.text.ILangEntry;
import net.minecraft.network.chat.Component;
import net.minecraft.network.codec.ByteBufCodecs;
Expand All @@ -22,7 +22,7 @@
* @since 10.2.1
*/
@NothingNullByDefault
public enum SecurityMode implements IIncrementalEnum<SecurityMode>, IHasTextComponent, StringRepresentable {
public enum SecurityMode implements IIncrementalEnum<SecurityMode>, IHasEnumNameTextComponent, StringRepresentable {
/**
* Public Security: Everyone is allowed access.
*/
Expand Down
15 changes: 15 additions & 0 deletions src/api/java/mekanism/api/text/IHasTextComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.network.chat.Component;
import net.neoforged.neoforge.common.TranslatableEnum;
import org.jetbrains.annotations.NotNull;

@MethodsReturnNonnullByDefault
public interface IHasTextComponent {
Expand All @@ -14,4 +16,17 @@ public interface IHasTextComponent {
* Gets the text component that represents this object.
*/
Component getTextComponent();

/**
* Helper interface that also implements Neo's TranslatableEnum interface
* @since 10.7.3
*/
interface IHasEnumNameTextComponent extends IHasTextComponent, TranslatableEnum {

@NotNull
@Override
default Component getTranslatedName() {
return getTextComponent();
}
}
}
16 changes: 16 additions & 0 deletions src/api/java/mekanism/api/text/IHasTranslationKey.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package mekanism.api.text;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.network.chat.Component;
import net.neoforged.neoforge.common.TranslatableEnum;
import org.jetbrains.annotations.NotNull;

@MethodsReturnNonnullByDefault
public interface IHasTranslationKey {
Expand All @@ -9,4 +12,17 @@ public interface IHasTranslationKey {
* Gets the translation key for this object.
*/
String getTranslationKey();

/**
* Helper interface that also implements Neo's TranslatableEnum interface
* @since 10.7.3
*/
interface IHasEnumNameTranslationKey extends IHasTranslationKey, TranslatableEnum {

@NotNull
@Override
default Component getTranslatedName() {
return TextComponentUtil.translate(getTranslationKey());
}
}
}
1 change: 1 addition & 0 deletions src/api/java/mekanism/api/text/TextComponentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.material.Fluid;
import net.neoforged.neoforge.common.TranslatableEnum;
import net.neoforged.neoforge.fluids.FluidStack;

public class TextComponentUtil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private void addAdvancements() {
}

private void addMisc() {
addModInfo("Additions module for Mekanism, contains things that don't quite fit in the other modules");
addModInfo("Additions module for Mekanism, contains miscellaneous things that do not thematically fit in the other modules");
addPackData(AdditionsLang.MEKANISM_ADDITIONS, AdditionsLang.PACK_DESCRIPTION);
add(AdditionsLang.CHANNEL, "Channel: %1$s");
add(AdditionsLang.CHANNEL_CHANGE, "Channel changed to: %1$s");
Expand Down

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

Loading

0 comments on commit 49a5b9b

Please sign in to comment.