当前位置: 首页>>代码示例>>Java>>正文


Java ItemStack.getChatComponent方法代码示例

本文整理汇总了Java中net.minecraft.item.ItemStack.getChatComponent方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.getChatComponent方法的具体用法?Java ItemStack.getChatComponent怎么用?Java ItemStack.getChatComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.item.ItemStack的用法示例。


在下文中一共展示了ItemStack.getChatComponent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDeathMessage

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Gets the death message that is displayed when the player dies
 */
public IChatComponent getDeathMessage(EntityLivingBase p_151519_1_)
{
    ItemStack itemstack = this.damageSourceEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.damageSourceEntity).getHeldItem() : null;
    String s = "death.attack." + this.damageType;
    String s1 = s + ".item";
    return itemstack != null && itemstack.hasDisplayName() && StatCollector.canTranslate(s1) ? new ChatComponentTranslation(s1, new Object[] {p_151519_1_.getDisplayName(), this.damageSourceEntity.getDisplayName(), itemstack.getChatComponent()}): new ChatComponentTranslation(s, new Object[] {p_151519_1_.getDisplayName(), this.damageSourceEntity.getDisplayName()});
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:11,代码来源:EntityDamageSource.java

示例2: getDeathMessage

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Gets the death message that is displayed when the player dies
 */
public IChatComponent getDeathMessage(EntityLivingBase p_151519_1_)
{
    IChatComponent ichatcomponent = this.indirectEntity == null ? this.damageSourceEntity.getDisplayName() : this.indirectEntity.getDisplayName();
    ItemStack itemstack = this.indirectEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.indirectEntity).getHeldItem() : null;
    String s = "death.attack." + this.damageType;
    String s1 = s + ".item";
    return itemstack != null && itemstack.hasDisplayName() && StatCollector.canTranslate(s1) ? new ChatComponentTranslation(s1, new Object[] {p_151519_1_.getDisplayName(), ichatcomponent, itemstack.getChatComponent()}): new ChatComponentTranslation(s, new Object[] {p_151519_1_.getDisplayName(), ichatcomponent});
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:12,代码来源:EntityDamageSourceIndirect.java

示例3: getDeathMessage

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public IChatComponent getDeathMessage()
{
    if (this.combatEntries.size() == 0)
    {
        return new ChatComponentTranslation("death.attack.generic", new Object[] {this.fighter.getDisplayName()});
    }
    else
    {
        CombatEntry combatentry = this.func_94544_f();
        CombatEntry combatentry1 = (CombatEntry)this.combatEntries.get(this.combatEntries.size() - 1);
        IChatComponent ichatcomponent1 = combatentry1.getDamageSrcDisplayName();
        Entity entity = combatentry1.getDamageSrc().getEntity();
        IChatComponent ichatcomponent;

        if (combatentry != null && combatentry1.getDamageSrc() == DamageSource.fall)
        {
            IChatComponent ichatcomponent2 = combatentry.getDamageSrcDisplayName();

            if (combatentry.getDamageSrc() != DamageSource.fall && combatentry.getDamageSrc() != DamageSource.outOfWorld)
            {
                if (ichatcomponent2 != null && (ichatcomponent1 == null || !ichatcomponent2.equals(ichatcomponent1)))
                {
                    Entity entity1 = combatentry.getDamageSrc().getEntity();
                    ItemStack itemstack1 = entity1 instanceof EntityLivingBase ? ((EntityLivingBase)entity1).getHeldItem() : null;

                    if (itemstack1 != null && itemstack1.hasDisplayName())
                    {
                        ichatcomponent = new ChatComponentTranslation("death.fell.assist.item", new Object[] {this.fighter.getDisplayName(), ichatcomponent2, itemstack1.getChatComponent()});
                    }
                    else
                    {
                        ichatcomponent = new ChatComponentTranslation("death.fell.assist", new Object[] {this.fighter.getDisplayName(), ichatcomponent2});
                    }
                }
                else if (ichatcomponent1 != null)
                {
                    ItemStack itemstack = entity instanceof EntityLivingBase ? ((EntityLivingBase)entity).getHeldItem() : null;

                    if (itemstack != null && itemstack.hasDisplayName())
                    {
                        ichatcomponent = new ChatComponentTranslation("death.fell.finish.item", new Object[] {this.fighter.getDisplayName(), ichatcomponent1, itemstack.getChatComponent()});
                    }
                    else
                    {
                        ichatcomponent = new ChatComponentTranslation("death.fell.finish", new Object[] {this.fighter.getDisplayName(), ichatcomponent1});
                    }
                }
                else
                {
                    ichatcomponent = new ChatComponentTranslation("death.fell.killer", new Object[] {this.fighter.getDisplayName()});
                }
            }
            else
            {
                ichatcomponent = new ChatComponentTranslation("death.fell.accident." + this.func_94548_b(combatentry), new Object[] {this.fighter.getDisplayName()});
            }
        }
        else
        {
            ichatcomponent = combatentry1.getDamageSrc().getDeathMessage(this.fighter);
        }

        return ichatcomponent;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:66,代码来源:CombatTracker.java


注:本文中的net.minecraft.item.ItemStack.getChatComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。