Java Code Examples for net.minecraft.client.resources.I18n#hasKey()

The following examples show how to use net.minecraft.client.resources.I18n#hasKey() . 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: SimpleTextWidget.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    String text = formatLocale.isEmpty() ? (I18n.hasKey(lastText) ? I18n.format(lastText) : lastText) : I18n.format(formatLocale, lastText);
    Position position = getPosition();
    fontRenderer.drawString(text,
        position.x - fontRenderer.getStringWidth(text) / 2,
        position.y - fontRenderer.FONT_HEIGHT / 2, color);
    GlStateManager.color(1.0f, 1.0f, 1.0f);
}
 
Example 2
Source File: OrePrefix.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public String getLocalNameForItem(Material material) {
    String specfiedUnlocalized = "item." + material.toString() + "." + this.name();
    if (I18n.hasKey(specfiedUnlocalized)) return I18n.format(specfiedUnlocalized);
    String unlocalized = "item.material.oreprefix." + this.name();
    String matLocalized = material.getLocalizedName();
    String formatted = I18n.format(unlocalized, matLocalized);
    return formatted.equals(unlocalized) ? matLocalized : formatted;
}
 
Example 3
Source File: MetaItem.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, @Nullable World worldIn, List<String> lines, ITooltipFlag tooltipFlag) {
    T item = getItem(itemStack);
    if (item == null) return;
    String unlocalizedTooltip = "metaitem." + item.unlocalizedName + ".tooltip";
    if (I18n.hasKey(unlocalizedTooltip)) {
        lines.addAll(Arrays.asList(I18n.format(unlocalizedTooltip).split("/n")));
    }

    IElectricItem electricItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null);
    if (electricItem != null) {
        lines.add(I18n.format("metaitem.generic.electric_item.tooltip",
            electricItem.getCharge(),
            electricItem.getMaxCharge(),
            GTValues.VN[electricItem.getTier()]));
    }

    IFluidHandlerItem fluidHandler = ItemHandlerHelper.copyStackWithSize(itemStack, 1)
        .getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
    if (fluidHandler != null) {
        IFluidTankProperties fluidTankProperties = fluidHandler.getTankProperties()[0];
        FluidStack fluid = fluidTankProperties.getContents();
        if (fluid != null) {
            lines.add(I18n.format("metaitem.generic.fluid_container.tooltip",
                fluid.amount,
                fluidTankProperties.getCapacity(),
                fluid.getLocalizedName()));
        } else lines.add(I18n.format("metaitem.generic.fluid_container.tooltip_empty"));
    }

    for (IItemBehaviour behaviour : getBehaviours(itemStack)) {
        behaviour.addInformation(itemStack, lines);
    }
}
 
Example 4
Source File: VariantBlock.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, ITooltipFlag advanced) {
    //tier less tooltip like: tile.turbine_casing.tooltip
    String unlocalizedVariantTooltip = getUnlocalizedName() + ".tooltip";
    if (I18n.hasKey(unlocalizedVariantTooltip))
        tooltip.addAll(Arrays.asList(I18n.format(unlocalizedVariantTooltip).split("/n")));
    //item specific tooltip: tile.turbine_casing.bronze_gearbox.tooltip
    String unlocalizedTooltip = stack.getUnlocalizedName() + ".tooltip";
    if (I18n.hasKey(unlocalizedTooltip))
        tooltip.addAll(Arrays.asList(I18n.format(unlocalizedTooltip).split("/n")));
}
 
Example 5
Source File: ItemPL.java    From Production-Line with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> list, boolean bool) {
    int i = 1;
    String unLocal = this.getUnlocalizedName() + ".desc" + i;

    while (I18n.hasKey(unLocal)) {
        list.add(I18n.format(unLocal));
        i++;
        unLocal = this.getUnlocalizedName() + ".desc" + i;
    }
}
 
Example 6
Source File: ItemMulti.java    From Production-Line with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> list, boolean bool) {
    int i = 1;
    String unLocal = this.getUnlocalizedName(itemStack) + ".desc" + i;

    while (I18n.hasKey(unLocal)) {
        list.add(I18n.format(unLocal));
        i++;
        unLocal = this.getUnlocalizedName() + ".desc" + i;
    }
}