Use translation keys on RebornCore and CellItem. Thanks to Maz-T

This commit is contained in:
Tryank 2022-02-26 19:10:43 +08:00 committed by GitHub
parent b378f2dcb9
commit 4ce4d6c361
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -41,6 +41,7 @@ import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -183,6 +184,6 @@ public class FluidUtils {
} }
public static String getFluidName(@NotNull Fluid fluid) { public static String getFluidName(@NotNull Fluid fluid) {
return StringUtils.capitalize(Registry.FLUID.getId(fluid).getPath()); return new TranslatableText(fluid.getDefaultState().getBlockState().getBlock().getTranslationKey()).getString();
} }
} }

View file

@ -51,6 +51,7 @@ import net.minecraft.sound.SoundEvents;
import net.minecraft.tag.FluidTags; import net.minecraft.tag.FluidTags;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.TypedActionResult; import net.minecraft.util.TypedActionResult;
@ -166,7 +167,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
Fluid fluid = getFluid(itemStack); Fluid fluid = getFluid(itemStack);
if (fluid != Fluids.EMPTY) { if (fluid != Fluids.EMPTY) {
// TODO use translation keys for fluid and the cell https://fabric.asie.pl/wiki/tutorial:lang?s[]=translation might be useful // TODO use translation keys for fluid and the cell https://fabric.asie.pl/wiki/tutorial:lang?s[]=translation might be useful
return new LiteralText(WordUtils.capitalizeFully(FluidUtils.getFluidName(fluid).replaceAll("_", " ")) + " Cell"); return new LiteralText(new TranslatableText("item.techreborn.cell.fluid").getString().replace("$fluid$", FluidUtils.getFluidName(fluid)));
} }
return super.getName(itemStack); return super.getName(itemStack);
} }