Java Code Examples for net.minecraft.util.text.translation.I18n#canTranslate()

The following examples show how to use net.minecraft.util.text.translation.I18n#canTranslate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemFluidContainer.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Nonnull
public String getItemStackDisplayName(@Nonnull ItemStack stack)
{
    FluidStack fluidStack = getFluid(stack);
    if (fluidStack == null)
    {
        return super.getItemStackDisplayName(stack);
    }

    String unloc = this.getUnlocalizedNameInefficiently(stack);

    if (I18n.canTranslate(unloc + "." + fluidStack.getFluid().getName()))
    {
        return I18n.translateToLocal(unloc + "." + fluidStack.getFluid().getName());
    }

    return I18n.translateToLocalFormatted(unloc + ".filled.name", fluidStack.getLocalizedName());
}
 
Example 2
Source File: Tooltips.java    From TinkersToolLeveling with MIT License 6 votes vote down vote up
private static String getRawLevelString(int level) {
  if(level <= 0) {
    return "";
  }

  // try a basic translated string
  if(I18n.canTranslate("tooltip.level." + level)) {
    return I18n.translateToLocal("tooltip.level." + level);
  }

  // ok. try to find a modulo
  int i = 1;
  while(I18n.canTranslate("tooltip.level." + i)) {
    i++;
  }

  // get the modulo'd string
  String str = I18n.translateToLocal("tooltip.level." + (level % i));
  // and add +s!
  for(int j = level / i; j > 0; j--) {
    str += '+';
  }

  return str;
}
 
Example 3
Source File: JEICrusherRecipeCategory.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public String getTitle() {
	String key = "nei."+BaseMetals.MODID+".recipehandler.crusher.name";
	if(I18n.canTranslate(key)){
		return I18n.translateToLocal(key);
	} else {
		return "Crusher";
	}
}
 
Example 4
Source File: CrusherRecipeHandler.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public String getRecipeName() {
	String key = "nei."+BaseMetals.MODID+".recipehandler.crusher.name";
	if(I18n.canTranslate(key)){
		return I18n.translateToLocal(key);
	} else {
		return "Crusher";
	}
}