本文整理汇总了Java中net.minecraft.init.Items.NAME_TAG属性的典型用法代码示例。如果您正苦于以下问题:Java Items.NAME_TAG属性的具体用法?Java Items.NAME_TAG怎么用?Java Items.NAME_TAG使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.minecraft.init.Items
的用法示例。
在下文中一共展示了Items.NAME_TAG属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockActivated
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
final TileEntity tile = worldIn.getTileEntity(pos);
if (tile == null || !(tile instanceof TileApiary)) return false;
ItemStack heldItem = playerIn.getHeldItem(hand);
if (!heldItem.isEmpty() && heldItem.getItem() == Items.NAME_TAG) {
((TileApiary) tile).setCustomInventoryName(heldItem.getDisplayName());
} else {
playerIn.openGui(Bewitchment.instance, LibGui.APIARY.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}
示例2: onBlockActivated
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
final TileEntity tile1 = worldIn.getTileEntity(pos);
if (tile1 == null || !(tile1 instanceof TileOven)) return false;
ItemStack heldItem = playerIn.getHeldItem(hand);
if (!heldItem.isEmpty() && heldItem.getItem() == Items.NAME_TAG) {
((TileOven) tile1).setCustomName(heldItem.getDisplayName());
} else {
playerIn.openGui(Bewitchment.instance, LibGui.OVEN.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}
示例3: processInteract
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
ItemStack itemstack = player.getHeldItem(hand);
boolean flag = itemstack.getItem() == Items.NAME_TAG;
if (flag)
{
itemstack.interactWithEntity(player, this, hand);
return true;
}
else if (!this.func_190669_a(itemstack, this.getClass()) && this.isEntityAlive() && !this.isTrading() && !this.isChild())
{
if (this.buyingList == null)
{
this.populateBuyingList();
}
if (hand == EnumHand.MAIN_HAND)
{
player.addStat(StatList.TALKED_TO_VILLAGER);
}
if (!this.world.isRemote && !this.buyingList.isEmpty())
{
this.setCustomer(player);
player.displayVillagerTradeGui(this);
}
else if (this.buyingList.isEmpty())
{
return super.processInteract(player, hand);
}
return true;
}
else
{
return super.processInteract(player, hand);
}
}
示例4: processInteract
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
if (!super.processInteract(player, hand))
{
ItemStack itemstack = player.getHeldItem(hand);
if (itemstack.getItem() == Items.NAME_TAG)
{
itemstack.interactWithEntity(player, this, hand);
return true;
}
else if (this.getSaddled() && !this.isBeingRidden())
{
if (!this.world.isRemote)
{
player.startRiding(this);
}
return true;
}
else if (itemstack.getItem() == Items.SADDLE)
{
itemstack.interactWithEntity(player, this, hand);
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
示例5: onBlockActivated
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
TileEntity te = worldIn.getTileEntity(pos);
if(te instanceof TileEntityInstrumentPlayer)
{
TileEntityInstrumentPlayer player = (TileEntityInstrumentPlayer)te;
boolean hasSlot = false;
ItemStack is = playerIn.getHeldItemMainhand();
if(is.getItem() == Clef.itemInstrument && !playerIn.isSneaking())
{
if(is.getTagCompound() == null && !worldIn.isRemote)
{
InstrumentLibrary.assignRandomInstrument(is);
}
//Find a free slot
for(int i = 0; i < player.getSizeInventory(); i++)
{
ItemStack is1 = player.getStackInSlot(i);
if(is1.isEmpty())
{
hasSlot = true;
worldIn.playSound(null, pos.getX() + 0.5D, pos.getY() + 1D, pos.getZ() + 0.5D, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
if(!worldIn.isRemote)
{
player.setInventorySlotContents(i, is);
player.markDirty();
playerIn.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
playerIn.inventory.markDirty();
worldIn.notifyBlockUpdate(pos, state, state, 3);
}
break;
}
}
}
else if(is.getItem() == Items.NAME_TAG && is.hasDisplayName())
{
boolean full = true;
for(int i = 0; i < 9 ; i++)
{
if(player.getStackInSlot(i).isEmpty())
{
full = false;
break;
}
}
if(!full)
{
return false;
}
if(worldIn.isRemote)
{
for(Instrument instrument : InstrumentLibrary.instruments)
{
if(instrument.info.itemName.equalsIgnoreCase(is.getDisplayName()))
{
Clef.channel.sendToServer(new PacketCreateInstrument(instrument.info.itemName, pos));
break;
}
}
}
return true;
}
if(!hasSlot && !player.justCreatedInstrument)
{
FMLNetworkHandler.openGui(playerIn, Clef.instance, 0, worldIn, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
return false;
}
示例6: execute
@Override
public void execute(Side side, EntityPlayer player)
{
if(Clef.config.creatableInstruments == 0)
{
return;
}
TileEntity te = player.world.getTileEntity(pos);
if(te instanceof TileEntityInstrumentPlayer)
{
TileEntityInstrumentPlayer player1 = (TileEntityInstrumentPlayer)te;
boolean full = true;
for(int i = 0; i < 9 ; i++)
{
if(player1.getStackInSlot(i) == null)
{
full = false;
break;
}
}
if(full)
{
ItemStack is1 = player.getHeldItemMainhand();
if(is1.getItem() == Items.NAME_TAG && is1.hasDisplayName())
{
Instrument ins = null;
for(Instrument instrument : InstrumentLibrary.instruments)
{
if(instrument.info.itemName.equals(instrumentName))
{
ins = instrument;
break;
}
}
if(ins == null)
{
if(Clef.config.creatableInstruments == 1 || Clef.config.creatableInstruments == 3)
{
InstrumentLibrary.requestInstrument(instrumentName, player);
}
}
else if(Clef.config.creatableInstruments < 2)
{
return;
}
for(int i = 0; i < 9; i++)
{
player1.setInventorySlotContents(i, null);
}
ItemStack is = new ItemStack(Clef.itemInstrument, 1, 0);
NBTTagCompound tag = new NBTTagCompound();
tag.setString("itemName", instrumentName);
is.setTagCompound(tag);
InventoryHelper.spawnItemStack(player.world, pos.getX() + 0.5D, pos.getY() + 1D, pos.getZ() + 0.5D, is);
player.world.playSound(null, pos.getX() + 0.5D, pos.getY() + 1D, pos.getZ() + 0.5D, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((player.world.rand.nextFloat() - player.world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
player1.markDirty();
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
player.inventory.markDirty();
player1.justCreatedInstrument = true;
}
}
}
return;
}
示例7: applyPlayerInteraction
/**
* Applies the given player interaction to this Entity.
*/
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand stack)
{
ItemStack itemstack = player.getHeldItem(stack);
if (!this.hasMarker() && itemstack.getItem() != Items.NAME_TAG)
{
if (!this.world.isRemote && !player.isSpectator())
{
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemstack);
if (itemstack.func_190926_b())
{
EntityEquipmentSlot entityequipmentslot1 = this.func_190772_a(vec);
EntityEquipmentSlot entityequipmentslot2 = this.isDisabled(entityequipmentslot1) ? entityequipmentslot : entityequipmentslot1;
if (this.func_190630_a(entityequipmentslot2))
{
this.swapItem(player, entityequipmentslot2, itemstack, stack);
}
}
else
{
if (this.isDisabled(entityequipmentslot))
{
return EnumActionResult.FAIL;
}
if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.HAND && !this.getShowArms())
{
return EnumActionResult.FAIL;
}
this.swapItem(player, entityequipmentslot, itemstack, stack);
}
return EnumActionResult.SUCCESS;
}
else
{
return EnumActionResult.SUCCESS;
}
}
else
{
return EnumActionResult.PASS;
}
}