本文整理汇总了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;
}
示例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());
}
}
}
示例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);
}
示例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()});
}
示例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;
}
}
示例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());
}
}
}
示例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;
}
}
}
示例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);
}
}
示例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());
}
}
}
示例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());
}
}
}
示例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});
}
示例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;
}
}
示例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;
}
}
示例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());
}
}
}
示例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());
}
}