當前位置: 首頁>>代碼示例>>Java>>正文


Java I18n.hasKey方法代碼示例

本文整理匯總了Java中net.minecraft.client.resources.I18n.hasKey方法的典型用法代碼示例。如果您正苦於以下問題:Java I18n.hasKey方法的具體用法?Java I18n.hasKey怎麽用?Java I18n.hasKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.client.resources.I18n的用法示例。


在下文中一共展示了I18n.hasKey方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleFluidContainerTooltip

import net.minecraft.client.resources.I18n; //導入方法依賴的package包/類
private void handleFluidContainerTooltip(ItemTooltipEvent event) {
    FluidStack fluidStack = FluidUtil.getFluidContained(event.getItemStack());
    if (fluidStack != null && fluidStack.amount > 0) {
        String key = "gui.tooltip.item." + fluidStack.getFluid().getName() + "_bucket";
        if (I18n.hasKey(key)) {
            if (event.getToolTip().get(event.getToolTip().size() - 1).contains("Minecraft Forge")) {
                // bit of a kludge!  otherwise the blue "Minecraft Forge" string gets shown twice
                event.getToolTip().remove(event.getToolTip().size() - 1);
            }
            String prefix = "";
            if (!FluidRegistry.getDefaultFluidName(fluidStack.getFluid()).startsWith(Names.MOD_ID)) {
                // fluid is owned by another mod; let's make it clear that this tooltip applies to PneumaticCraft
                prefix = TextFormatting.DARK_AQUA + "" + TextFormatting.ITALIC + "[" + Names.MOD_NAME + "] ";
            }
            if (PneumaticCraftRepressurized.proxy.isSneakingInGui()) {
                String translatedInfo = TextFormatting.AQUA + I18n.format(key);
                event.getToolTip().addAll(PneumaticCraftUtils.convertStringIntoList(prefix + translatedInfo, 40));
            } else {
                event.getToolTip().add(TextFormatting.AQUA + I18n.format("gui.tooltip.sneakForInfo"));
            }
        }
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:24,代碼來源:ClientEventHandler.java

示例2: addInformation

import net.minecraft.client.resources.I18n; //導入方法依賴的package包/類
@Override
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, ITooltipFlag advanced) {
    super.addInformation(stack, player, tooltip, advanced);
    if(this.infoState == 0){
        if(I18n.hasKey("desc." + this.getRegistryName().toString() + ".name")){
            this.infoState = 2;
        } else {
            this.infoState = 1;
        }
    }
    if(this.infoState == 2 || advanced.isAdvanced()){
        String local = I18n.format("desc." + this.getRegistryName().toString() + ".name");
        for(String s : local.split(" NL ")){
            tooltip.add(s.replace(" NL ", ""));
        }
    }
}
 
開發者ID:canitzp,項目名稱:Metalworks,代碼行數:18,代碼來源:BlockBase.java

示例3: getDeathMessage

import net.minecraft.client.resources.I18n; //導入方法依賴的package包/類
/**
 * Returns the message to be displayed on player death.
 */
@Override
public ITextComponent getDeathMessage(EntityLivingBase par1EntityLivingBase) {
    String messageMeta = "";
    int messageNumber = par1EntityLivingBase.getRNG().nextInt(deathMessages) + 1;
    messageMeta = messageNumber + "";

    EntityLivingBase entitylivingbase1 = par1EntityLivingBase.getAttackingEntity();
    String s = "death.attack." + damageType + messageMeta;
    String s1 = s + ".player";
    return entitylivingbase1 != null && I18n.hasKey(s1) ?
            new TextComponentTranslation(s1, par1EntityLivingBase.getDisplayName(), entitylivingbase1.getDisplayName()) :
            new TextComponentTranslation(s, par1EntityLivingBase.getDisplayName());
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:17,代碼來源:DamageSourcePneumaticCraft.java

示例4: onResourceManagerReload

import net.minecraft.client.resources.I18n; //導入方法依賴的package包/類
public void onResourceManagerReload(IResourceManager resourceManager)
{
    this.soundRegistry.clearMap();

    for (String s : resourceManager.getResourceDomains())
    {
        try
        {
            for (IResource iresource : resourceManager.getAllResources(new ResourceLocation(s, "sounds.json")))
            {
                try
                {
                    Map<String, SoundList> map = this.getSoundMap(iresource.getInputStream());

                    for (Entry<String, SoundList> entry : map.entrySet())
                    {
                        this.loadSoundResource(new ResourceLocation(s, (String)entry.getKey()), (SoundList)entry.getValue());
                    }
                }
                catch (RuntimeException runtimeexception)
                {
                    LOGGER.warn((String)"Invalid sounds.json", (Throwable)runtimeexception);
                }
            }
        }
        catch (IOException var11)
        {
            ;
        }
    }

    for (ResourceLocation resourcelocation : this.soundRegistry.getKeys())
    {
        SoundEventAccessor soundeventaccessor = (SoundEventAccessor)this.soundRegistry.getObject(resourcelocation);

        if (soundeventaccessor.getSubtitle() instanceof TextComponentTranslation)
        {
            String s1 = ((TextComponentTranslation)soundeventaccessor.getSubtitle()).getKey();

            if (!I18n.hasKey(s1))
            {
                LOGGER.debug("Missing subtitle {} for event: {}", new Object[] {s1, resourcelocation});
            }
        }
    }

    for (ResourceLocation resourcelocation1 : this.soundRegistry.getKeys())
    {
        if (SoundEvent.REGISTRY.getObject(resourcelocation1) == null)
        {
            LOGGER.debug("Not having sound event for: {}", new Object[] {resourcelocation1});
        }
    }

    this.sndManager.reloadSoundSystem();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:57,代碼來源:SoundHandler.java


注:本文中的net.minecraft.client.resources.I18n.hasKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。