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


Java ItemStack.hasDisplayName方法代碼示例

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


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

示例1: setItemValues

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public void setItemValues(ItemStack stack, boolean p_175112_2_)
{
    this.patterns = null;
    NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag");

    if (nbttagcompound != null && nbttagcompound.hasKey("Patterns", 9))
    {
        this.patterns = nbttagcompound.getTagList("Patterns", 10).copy();
    }

    this.baseColor = p_175112_2_ ? func_190616_d(stack) : ItemBanner.getBaseColor(stack);
    this.patternList = null;
    this.colorList = null;
    this.patternResourceLocation = "";
    this.patternDataSet = true;
    this.field_190617_a = stack.hasDisplayName() ? stack.getDisplayName() : null;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:18,代碼來源:TileEntityBanner.java

示例2: onBlockPlacedBy

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Called by ItemBlocks after a block is set in the world, to allow post-place logic
 */
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);

    if (stack.hasDisplayName())
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityFurnace)
        {
            ((TileEntityFurnace)tileentity).setCustomInventoryName(stack.getDisplayName());
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:18,代碼來源:BlockFurnace.java

示例3: onBlockPlacedBy

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
	if (stack.hasDisplayName()) {
        TileEntity entity = worldIn.getTileEntity(pos);
        if (entity != null && entity instanceof TileEntityBase)
        		((TileEntityBase)entity).setCustomName(stack.getDisplayName());
    }
	
	super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
}
 
開發者ID:astronautlabs,項目名稱:rezolve,代碼行數:11,代碼來源:Machine.java

示例4: getDeathMessage

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Gets the death message that is displayed when the player dies
 */
public ITextComponent getDeathMessage(EntityLivingBase entityLivingBaseIn)
{
    ItemStack itemstack = this.damageSourceEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.damageSourceEntity).getHeldItemMainhand() : ItemStack.field_190927_a;
    String s = "death.attack." + this.damageType;
    String s1 = s + ".item";
    return !itemstack.func_190926_b() && itemstack.hasDisplayName() && I18n.canTranslate(s1) ? new TextComponentTranslation(s1, new Object[] {entityLivingBaseIn.getDisplayName(), this.damageSourceEntity.getDisplayName(), itemstack.getTextComponent()}): new TextComponentTranslation(s, new Object[] {entityLivingBaseIn.getDisplayName(), this.damageSourceEntity.getDisplayName()});
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:11,代碼來源:EntityDamageSource.java

示例5: canOpen

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Check whether this player can open an inventory locked with the given LockCode.
 */
public boolean canOpen(LockCode code)
{
    if (code.isEmpty())
    {
        return true;
    }
    else
    {
        ItemStack itemstack = this.getCurrentEquippedItem();
        return itemstack != null && itemstack.hasDisplayName() ? itemstack.getDisplayName().equals(code.getLock()) : false;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:16,代碼來源:EntityPlayer.java

示例6: onBlockPlacedBy

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
  super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
  if (stack.hasDisplayName()) {
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityMinecoprocessor) {
      ((TileEntityMinecoprocessor) tileentity).setName(stack.getDisplayName());
    }
  }
}
 
開發者ID:ToroCraft,項目名稱:Minecoprocessors,代碼行數:12,代碼來源:BlockMinecoprocessor.java

示例7: onItemRightClick

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
	if (world.isRemote)
		return stack;
	else {
		MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, player, true);

		if (movingobjectposition == null)
			return stack;
		else {
			if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
				int i = movingobjectposition.blockX;
				int j = movingobjectposition.blockY;
				int k = movingobjectposition.blockZ;

				if (!world.canMineBlock(player, i, j, k))
					return stack;

				if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack))
					return stack;

				if (world.getBlock(i, j, k) instanceof BlockLiquid) {
					Entity entity = spawnEntity(world, stack.getItemDamage(), i, j, k);

					if (entity != null) {
						if (entity instanceof EntityLivingBase && stack.hasDisplayName())
							((EntityLiving) entity).setCustomNameTag(stack.getDisplayName());

						if (!player.capabilities.isCreativeMode)
							stack.stackSize--;
					}
				}
			}

			return stack;
		}
	}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:39,代碼來源:ItemEntityEgg.java

示例8: getRotation

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
protected void getRotation(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack)
{
    /*
    0 - bottom
    1 - top
    2 - north
    3 - south
    4 - west
    5 - east
    */

    if (itemstack.hasDisplayName())
    {
        ((TileKT) world.getTileEntity(x, y, z)).setCustomName(itemstack.getDisplayName());
    }

    int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

    if (l == 0)
    {
        world.setBlockMetadataWithNotify(x, y, z, 2, 2);
    }

    if (l == 1)
    {
        world.setBlockMetadataWithNotify(x, y, z, 5, 2);
    }

    if (l == 2)
    {
        world.setBlockMetadataWithNotify(x, y, z, 3, 2);
    }

    if (l == 3)
    {
        world.setBlockMetadataWithNotify(x, y, z, 4, 2);
    }
}
 
開發者ID:koravel,項目名稱:ElementalElaboration,代碼行數:39,代碼來源:RotatableBlock.java

示例9: onBlockPlacedBy

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Called by ItemBlocks after a block is set in the world, to allow post-place logic
 */
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    worldIn.setBlockState(pos, state.withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer)), 2);

    if (stack.hasDisplayName())
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityDispenser)
        {
            ((TileEntityDispenser)tileentity).setCustomName(stack.getDisplayName());
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:18,代碼來源:BlockDispenser.java

示例10: onBlockPlacedBy

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Called by ItemBlocks after a block is set in the world, to allow post-place logic
 */
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    worldIn.setBlockState(pos, state.withProperty(FACING, BlockPistonBase.getFacingFromEntity(pos, placer)), 2);

    if (stack.hasDisplayName())
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityDispenser)
        {
            ((TileEntityDispenser)tileentity).setCustomName(stack.getDisplayName());
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:18,代碼來源:BlockDispenser.java

示例11: 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

示例12: processInteract

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (itemstack.getItem() == Items.SPAWN_EGG)
    {
        if (!this.world.isRemote)
        {
            Class <? extends Entity > oclass = (Class)EntityList.field_191308_b.getObject(ItemMonsterPlacer.func_190908_h(itemstack));

            if (oclass != null && this.getClass() == oclass)
            {
                EntityAgeable entityageable = this.createChild(this);

                if (entityageable != null)
                {
                    entityageable.setGrowingAge(-24000);
                    entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
                    this.world.spawnEntityInWorld(entityageable);

                    if (itemstack.hasDisplayName())
                    {
                        entityageable.setCustomNameTag(itemstack.getDisplayName());
                    }

                    if (!player.capabilities.isCreativeMode)
                    {
                        itemstack.func_190918_g(1);
                    }
                }
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:41,代碼來源:EntityAgeable.java

示例13: canOpen

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Check whether this player can open an inventory locked with the given LockCode.
 */
public boolean canOpen(LockCode code)
{
    if (code.isEmpty())
    {
        return true;
    }
    else
    {
        ItemStack itemstack = this.getHeldItemMainhand();
        return itemstack != null && itemstack.hasDisplayName() ? itemstack.getDisplayName().equals(code.getLock()) : false;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:16,代碼來源:EntityPlayer.java

示例14: onBlockPlacedBy

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Called by ItemBlocks after a block is set in the world, to allow post-place logic
 */
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);

    if (stack.hasDisplayName())
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityHopper)
        {
            ((TileEntityHopper)tileentity).setCustomName(stack.getDisplayName());
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:18,代碼來源:BlockHopper.java

示例15: onBlockPlacedBy

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    if(stack.hasDisplayName()) {
        ((TileEntityChalkBase)worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName());
    }
}
 
開發者ID:Drazuam,項目名稱:RunicArcana,代碼行數:7,代碼來源:BlockChalkBase.java


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