本文整理匯總了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"));
}
}
}
}
示例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 ", ""));
}
}
}
示例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());
}
示例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();
}