Java Code Examples for net.minecraft.init.Items#NAME_TAG

The following examples show how to use net.minecraft.init.Items#NAME_TAG . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: TofuCraftReload   File: EntityTofunian.java    License: MIT License 5 votes vote down vote up
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.holdingSpawnEggOfClass(itemstack, this.getClass()) && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking()) {
        if (this.buyingList == null) {
            this.initTrades();
        }

        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);
    }
}
 
Example 2
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing face, float par7, float par8, float par9){
    if(player.isSneaking()) return false;
    else {
        ItemStack stack = player.getHeldItem(hand);
        if(!world.isRemote && stack.getItem() == Items.NAME_TAG && stack.hasDisplayName()) {
            TileEntityStationMarker stationMarker = (TileEntityStationMarker)world.getTileEntity(pos);
            stationMarker.setStationName(stack.getDisplayName());
            return true;
        } else {
            return super.onBlockActivated(world, pos, state, player, hand, face, par7, par8, par9);
        }
    }
}